sql server - SQL reading from a comma delimited field and then bringing data back in comma delimited format -
i have data in string format 3,2,1 in table column. have lookup table tells me file name associated file table looks this id (int) name ------------------ 1 file 1 2 file 2 what want send string 3,2,1 , data file 1, file 2 separate column can refer in displaying. mind addition existing stored procedure that's why want 1 string row back thanks in advance help you may want write code this. below code it's example put on right track. let me know if have questions declare @input varchar(max) declare @index1 int declare @index2 int declare @id varchar(10) declare @str varchar(max) declare @result varchar(max) set @input = '3,2,1'; set @str = reverse(@input) set @index1 = 1; set @index2 = charindex(',', @str) set @id = substring(@str, @index1, @index2 -@index1) set @result = 'file ' + @id + ',' while (@index2 > 0 ) begin set @str = substring(@str, @index2 + 1, len(@str) -@index1) set @id = substrin...