Sample Header Ad - 728x90

Mssql subquery inside a substring

1 vote
2 answers
1832 views
I need to remove the last character of my subquery but I cannot figure out how to reference my subquery in the subselect as I need the length of it. The subselect collects all rows and converts them into a single string by appending them with a separator ";". This is what I need: ``` (SUBSTRING( (SELECT d1.name +'; ' FROM data1 d1 inner join data2 d2 on d1.id = d2.id WHERE d1.id = dOfOutterSelect.id ORDER BY d1.CreatedOn FOR XML PATH('') ), LENGTH(),1)) As "Row name",
Asked by Symbiose Studios (13 rep)
Dec 4, 2020, 01:51 PM
Last activity: Dec 7, 2020, 01:55 PM