all groups > sql server mseq > august 2006 >
You're in the

sql server mseq

group:

sqlexec


sqlexec shif
8/27/2006 1:40:02 AM
sql server mseq:
Hi
How can i execute a piece of sqlstmt which is stored in a string variable
from query analyser.
for ex:@var1="select name,code from" + @var2
--
Re: sqlexec Hari Prasad
8/27/2006 9:18:40 AM
Hi,

This is actually a dynamic SQL and can be executed using one of the below :-

EXEC(@Var1)

or

exec sp_executesql @Var1

Thanks
Hari
SQL Server MVP


[quoted text, click to view]

Re: sqlexec Hugo Kornelis
8/27/2006 10:14:45 PM
[quoted text, click to view]

Hi shif,

http://www.sommarskog.se/dynamic_sql.html

--
AddThis Social Bookmark Button