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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 it is possible to get values from sp_executesql

Author  Topic 

marconi8
Yak Posting Veteran

73 Posts

Posted - 2003-05-12 : 04:16:24
for example

sp_executesql=N'SELECT @VAR = COUNT(ID) FROM .....


i call sp_executesql in sp, and after sp_executesql i must to operate this this variable @VAR , cannot get a var i can see only result sets returned by sp_executesql, but how to get parameter from sp_executesql


thanks

Andraax
Aged Yak Warrior

790 Posts

Posted - 2003-05-12 : 04:25:44
Hi!

The statement executed by sp_executesql is not in the same context as so you cannot reference the same variables within it as outside it.

An option is to use something like:


declare @tmp table (var int)
declare @var int

insert @tmp
exec sp_executesql N'SELECT ....

select @var=var
from @tmp


Should work. (not tested)

Go to Top of Page
   

- Advertisement -