May 4, 2009 at 11:52 pm
HI friends
I have a requirement of creating temporary table dynamically inside a stored procedure . i have done like this
DECLARE @SQL1 AS VARCHAR(MAX)
SET @SQL1 =('Select '+@result +' into #Table21 from '+ @CompareTableName +' where ToEligibleVersion= '+ @Version2)
EXEC(@SQL1)
print @SQL1
where all parameters are passed .
when i check the print statement every thing is fine , but #table21 is not created .
is there any problem with EXEC command .
can any one let me to solve the problem
Thanks
nmsreddi
May 5, 2009 at 5:04 am
temp table created as part of dynamic query will not be visible outside the scope of the dynamic query. Try creating global temp table if that suits your purpose.
May 5, 2009 at 10:13 pm
thanks for your reply , i have done the same , my problem solved by using global temp tables
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply