General information
Forum:
Microsoft SQL Server
Why you call your execute the sql is executed in another batch. This means that your temp table is local to that batch, not the one the called the exec function. To get around this you need to prefix your table with 2 pound signs (##). That will make the temp table global.
>Hello everyone,
>I am trying to create a temp table and then insert some records in there:
>
>DECLARE @StrCreate varChar(500)
>SET @StrCreate = 'CREATE TABLE #curReport (ID Int, F1, F2...)' -- String,actually gets build for crosstab report
>EXECUTE(@StrCreate)
>SELECT * FROM #curReport
>
>It does not see #curReport after EXECUTE.
>If there any way around this.
>Please help.
>
>Thanks in advance..
Previous
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only