Skip to main content
Rollback to Revision 1
Source Link
Hogan
  • 70.7k
  • 10
  • 82
  • 119
 select
   distinct  
    stuff((
        select ',' + u.username
        from users u
        where u.username = username
        order by u.username
        for xml path('')
    ),1,21,'') as userlist
from users
group by username

had a typo before, the above works

 select
   distinct  
    stuff((
        select ',' + u.username
        from users u
        where u.username = username
        order by u.username
        for xml path('')
    ),1,2,'') as userlist
from users
group by username

had a typo before, the above works

 select
   distinct  
    stuff((
        select ',' + u.username
        from users u
        where u.username = username
        order by u.username
        for xml path('')
    ),1,1,'') as userlist
from users
group by username

had a typo before, the above works

edited body
Source Link
Leniel Maccaferri
  • 102.7k
  • 46
  • 380
  • 495
 select
   distinct  
    stuff((
        select ',' + u.username
        from users u
        where u.username = username
        order by u.username
        for xml path('')
    ),1,12,'') as userlist
from users
group by username

had a typo before, the above works

 select
   distinct  
    stuff((
        select ',' + u.username
        from users u
        where u.username = username
        order by u.username
        for xml path('')
    ),1,1,'') as userlist
from users
group by username

had a typo before, the above works

 select
   distinct  
    stuff((
        select ',' + u.username
        from users u
        where u.username = username
        order by u.username
        for xml path('')
    ),1,2,'') as userlist
from users
group by username

had a typo before, the above works

Source Link
Hogan
  • 70.7k
  • 10
  • 82
  • 119

 select
   distinct  
    stuff((
        select ',' + u.username
        from users u
        where u.username = username
        order by u.username
        for xml path('')
    ),1,1,'') as userlist
from users
group by username

had a typo before, the above works