February 15, 2006 at 4:15 pm
Hi,
I tried to insert the rows returned by executing a dynamic sql statement into a table variable, like this
INSERT INTO @usertable EXEC ('SELECT * FROM users WHERE ... ')
The error is very clear "EXECUTE cannot be used as a source when inserting into a table variable." Is there any work around, without having to create a table?
Thanks.
February 15, 2006 at 4:19 pm
Hello Senthil,
Can you check this
SELECT select_list INTO table_variable
Thanks and have a nice day!!!
Lucky
February 15, 2006 at 4:29 pm
You mean like this
EXEC ('SELECT * FROM users WHERE...some conditions...INTO @usertable')
This is the error I get Incorrect syntax near the keyword 'into'. The select statement is built dynamically with some where conditions depending on parameters.
February 15, 2006 at 8:21 pm
Why not
INSERT INTO #usertable EXEC ('SELECT * FROM users WHERE ... ')
_____________
Code for TallyGenerator
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply