"Michi Albatross" <al***@netdot.ch> wrote in message
news:67**************************@posting.google.c om...
Is it possible to print the the value of a variable in a variable
what i mean:
Declare @test varchar(255)
Declare @foo varchar(255)
Declare @strSQL varchar(255)
set @test = 'Hallo'
Set @foo = '@test'
Print @foo
Set @strSQL = 'SELECT ' + @foo --Expected result is 'Hallo'
exec master..sp_ExecuteSQL @strSQL
How doess it work?
I hope you understand my problem
Thanks
I guess you're looking for something like this? See sp_executesql in BOL for
more details on the syntax.
Simon
Declare @test varchar(255)
Declare @foo varchar(255)
Declare @strSQL nvarchar(255)
set @test = 'Hallo'
Set @foo = @test
Print @foo
Set @strSQL = 'SELECT @foo'
exec sp_ExecuteSQL @strSQL, N'@foo varchar(255)', @foo = @test