Hi,
I have a query:
select name from Archive_man_live.dbo.sysco
lumns where id = (select id from Archive_man_live.dbo.sysob
jects where name = 'JOBS'
And I want to loop through all of the records to create a variable containing the 'name' value from each row seperated by a comma. I think my syntax is right for creating the growing variable, but I can't figure out how to loop through all records in T-SQL until the end of the recordset.
So,
DECLARE @String NVARCHAR(1000)
SELECT @String= ''
/* WHILE or FOR statement or DO UNTIL???? */
BEGIN
SELECT @String = @String & ',' & name
END
Thanks for any assistance,
Bonnie
Start Free Trial