SELECT STUFF( (SELECT ',' + convert(varchar(10),PID) FROM tt WHERE a='老王' FOR xml path('') ),1,1,'' )xml