I have a table UserAliases (UserId, Alias) with multiple aliases per user. I need to query it and return all aliases for a given user, the trick is to return them all in one column.
Example:
UserId/Alias 1/MrX 1/MrY 1/MrA 2/Abc 2/Xyz
I want the query result in the following format:
UserId/Alias 1/ MrX, MrY, MrA 2/ Abc, Xyz
Thank you.
I’m using SQL Server 2005.
p.s. actual T-SQL query would be appreciated 🙂
You can use a function with COALESCE.