Mombu the Microsoft Forum sponsored links

Go Back   Mombu the Microsoft Forum > Microsoft > SQL SERVER (TECHNET) > sqlexec
User Name
Password
REGISTER NOW! Mark Forums Read

sponsored links


Reply
 
1 27th August 10:52
External User
External User
 
Posts: 1
Default sqlexec


Hi
How can i execute a piece of sqlstmt which is stored in a string variable
from query ****yser.
for ex:@var1="select name,code from" + @var2
--
Thanks
  Reply With Quote


  sponsored links


2 27th August 19:35
hari prasad
External User
 
Posts: 1
Default sqlexec


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
  Reply With Quote
3 27th August 19:35
hugo kornelis
External User
 
Posts: 1
Default sqlexec


Hi shif,

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

--
Hugo Kornelis, SQL Server MVP
  Reply With Quote


  sponsored links


Reply


Thread Tools
Display Modes




Copyright 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666