Reading values into a variable without using a loop/cursor
Posted on 2011-09-26
many months ago I thought I remember seeing sql syntax that would allow me to create a variable and read/assign certain values to it without having to resort to a loop.
Here is my first try:
declare @result as varchar(8000)
select distinct @result = fName + ', ' from dbo.Person order by fName
I am hoping the @result variable would show me something like this:
Abby, John, Kenneth, etc....
P.S. Right now this is against SQL Server 2000.