I'm trying to create a query capable of concatenating the values in the ProfileItemID column with Microsoft SQL Server Management Studio.
Here's the query. First of all, I'm not sure if it's right because I get this error after running it.
SELECT RoomID, ',' + ProfileItemID
FROM RoomProfile
WHERE RoomID = 1829
FOR XML PATH('')
"Conversion failed when converting the varchar value ',' to data type int."
Attached is an image containing information I have of the table and images of the entire screen.
Hopefully, someone can please help me out. I really don't know what to do since I'm very new to SQL still.
Thank you in advance!
Table:
|----------------------------------------|
| RoomProfile |
|---------------------|------------------|
| RoomID | ProfileItemID |
|---------------------|------------------|
| 1829 | 28 |
|---------------------|------------------|
| 1829 | 103 |
|---------------------|------------------|
| 1829 | 104 |
|----------------------------------------|
Output:
|----------------------------------------|
| 1829 | 28, 103, 104 |
|----------------------------------------|