Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
peace
Constraint Violating Yak Guru
420 Posts |
Posted - 2014-07-16 : 22:07:37
|
how can i insert into a table/temp table.set @query = ' select... + '@pivot 'update... 'exec (@query) |
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
Posted - 2014-07-17 : 01:58:08
|
DECLARE @tab TABLE( ID Int)DECLARE @tSQL VARCHAR(MAX) = 'INSERT @tab VALUES( 1)'EXEC( @tSQL)/* Error :Msg 1087, Level 15, State 2, Line 3Must declare the table variable "@tab".*/GO-- to fix above error the table variable declaration should be as part of query string.DECLARE @tSQL VARCHAR(MAX) = 'DECLARE @tab TABLE( ID Int)INSERT @tab VALUES( 1)'EXEC( @tSQL)--Chandu |
|
|
|
|
|