how to send query output into a variable

how to send query output into a variable

 

  

Hello all,

I am running a query that generates a T-SQL script. I need to run that
script on a different server, which is straightforward enough with osql.
Problem is that the output of the first query is in several rows, and I need
it to be one string that can be passed to osql. I tried to use varchar(8000)
variable and concotenate the text with a loop, but that was a waste of time.
Any ideas?

Thanks


MS Sql Server LazyDBA home page