Код T-SQL для возврата строки с разделителями-запятыми в SQL Server 2000
Declare @Dept_id Varchar(20) Declare @str VARCHAR (8000) Declare @tempResults Table (Dept_id Int, Emp_String Varchar(8000)) Select @Dept_id = Min(Dept_id) from #temp_dept While @Dept_id IS NOT NULL Begin SET @str = ?? Select @str = @str + name + ?,? FROM #temp_dept Where Dept_id = @Dept_id If @str <> ?? SET @str = LEFT(@str, LEN(@str) -1) Insert into @tempResults values (@Dept_id, @str) Select @Dept_id = min(Dept_id) from #temp_dept where Dept_id > @Dept_id End Select * from @tempResults Drop table #temp_dept