declare @MyVar varchar(50) declare @MySQL nvarchar(50) select @MySQL = ' select @MyVar=''1'' ' exec sp_executesql @MySQL,N'@MyVar varchar(50) output',@MyVar output
print @myvar