Rahuul
Mr or Mrs. 500
Points: 581
More actions
April 5, 2004 at 3:52 am
#108029
hi all,
Is there a way by which we can run our variable? say for example:
declare @abc varchar(2000)
set @abc = 'select * from [sqlserver.com].[dbo].[db1].admin'
I want to run the above statement using @abc.
Thanks in advance!
Frank Kalis
SSC Guru
Points: 111183
April 5, 2004 at 4:00 am
#501729
http://www.sommarskog.se/dynamic_sql.html
Read the article and decide if that is the way for you to go
--Frank KalisMicrosoft SQL Server MVPWebmaster: http://www.insidesql.org/blogsMy blog: http://www.insidesql.org/blogs/frankkalis/[/url]
Out For Justice
SSCrazy
Points: 2733
April 6, 2004 at 2:53 am
#501830
Here is a simple example
Declare @sql nvarchar(100)
SET @sql = 'SELECT * FROM <mytable>'
EXEC sp_executesql @sql
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply