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 2005 Forums
 Transact-SQL (2005)
 grab output of dynamic sql and use as variable

Author  Topic 

dbist
Yak Posting Veteran

52 Posts

Posted - 2008-05-05 : 17:07:05
hello,

I'd like to know how I can grab the output of the following code and use it as variable:

declare @sql nvarchar(25)
set @sql = 'SELECT CURRENT_TIMESTAMP'
EXEC(@sql)

Thank you.

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2008-05-05 : 17:30:05
Maybe in SSIS package
Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2008-05-05 : 18:13:26
Use SP_EXECUTESQL to return a local variable as output from dynamic SQL.

You can read about how to do that in SQL Server 2005 Books Online.





CODO ERGO SUM
Go to Top of Page
   

- Advertisement -