sqlserver 查询int类型 in (字符串) 报转换int类型出错的问题
SELECT A.*,B.c_roleCode,B.c_roleName,(SELECT STUFF(( SELECT ',' +convert(VARCHAR, c_departName) FROM t_depart WHERE CHARINDEX(','+LTRIM(c_departId)+',',','+A.c_departIds+',')>0 FOR XML PATH('')), 1, 1, '') ) AS c_departNames FROM t_user AS A LEFT JOIN t_role AS B ON A.c_roleId=B.c_roleId
用 CHARINDEX(','+LTRIM(c_departId)+',',','+A.c_departIds+',')>0 来解决 c_departId为int类型 A.c_departIds为字符串类型