判断某个逗号隔开的字段中有某个值

FIND_IN_SET('a','a,b,c,d')CHARINDEX(','+'b'+',' , ','+'a,b,c'+',') > 0 替代

模仿mysql的group_concat的示例

1
SELECT id,     
2
       val=( SELECT [value] +','     
3
               FROM tb AS b     
4
               WHERE b.id = a.id
5
               FOR XML PATH('')  )     
6
FROM tb AS a      
7
GROUP BY id
1
SELECT id,     
2
       [val]=STUFF( (SELECT ','+[value]     
3
                     FROM tb AS b     
4
                     WHERE b.id = a.id     
5
                     FOR XML PATH('')) , 1 , 1 , '' )    
6
FROM tb AS a      
7
GROUP BY id