markcrosbie
SSC Rookie
Points: 46
More actions
March 21, 2013 at 11:51 am
#275416
How do I sleect from a populated temporary table using a dynamic query
declare @Tmp table (.....)
SET @SQLString =N'select * from @Tmp'
EXECUTE sp_executesql @SQLString
I am getting : Must declare the table variable "@Tmp".
Lynn Pettis
SSC Guru
Points: 442467
March 21, 2013 at 12:11 pm
#1599520
markcrosbie (3/21/2013)How do I sleect from a populated temporary table using a dynamic querydeclare @Tmp table (.....)SET @SQLString =N'select * from @Tmp'EXECUTE sp_executesql @SQLStringI am getting : Must declare the table variable "@Tmp".
markcrosbie (3/21/2013)
The table @Tmp is a table variable and it can't be used this way. You can create a temporary table (#Tmp) and what you are attenpting will work.
March 21, 2013 at 12:37 pm
#1599530
Aaah...thank you so much
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply