MSSQL 字符串XML 合成列
declare @str varchar(2000) set @str='1,2,3,4,6,8,5,9,10,11,12,13,14,15,16,17,18,19,20,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,52,53,54,55,56,57,25,27,28,58' Declare @x XML select @x = cast('<A>'+ replace(@str,',','</A><A>')+ '</A>' as xml) select * from ( select t.value('.','varchar(6)') as inVal from @x.nodes('/A') as x(t) ) as B where inVal=8
select Author_Name=STUFF((SELECT ','+Staffing_Name FROM View_Author_Score t WHERE related_table='T_Outside_Data' and t.related_table_id=d.id FOR XML PATH('')), 1, 1, '')