Click here to Skip to main content
15,888,610 members

can we use temproray tables in stored procedure which is having dynamic sql in it.

Revision 2
Hi Recently i tried to create one temp table before dynamic sql and i compiled the SP.
when i tried to execute the SP it is giving the error like my temp table doen't exist
ex:
SQL
PROCEDURE [dbo].[Proc_test]
as
begin
DECLARE @sqlstring NVARCHAR(4000)
select * into #test from xtable
SET @sqlstring='select * from #test'
end

now it is compiling fine but at the time of executing it is showing the error like
#test doesn't exist
Posted 2-Jan-13 2:59am by FranklinRemo.
Tags: ,