I am new to writing SQL scripts (at least anything more than SELECT * FROM X). I have run into a problem grouping a table by one value, and then joining values from another column into a single string.
I would like to perform a group by on a temp table, and then concatenate values of a column in the group together.
The table variable (edit), @categoriesToAdd, data structure is [SubscriberId int, CategoryId int].
What I am trying to do is something like (My understanding is that CONCAT is the bit missing from MSSQL):
SELECT SubscriberId,
CONCAT(CONVERT(VARCHAR(10), CategoryId) + ', ') as categoriesAdded
FROM @categoriesToAdd
GROUP BY SubscriberId
The concatenated category IDs for each subscriber would then look something like: 0001, 0002, 0003, 0004
Thanks!