I'm relatively new to T-SQL and looking through my predecessors scripts, I found a line I can't quite parse. It's a hard thing to look up on my own. Hoping for advice.
This line occurs inside a WHILE loop, but I don't think that matters. I believe functionally, that this is gathering the values from a column across a few rows that share an ID and concatenating them with commas into 1 field. But I don't know what this is called or how to look it up to use it myself.
What is this 'x' doing at the end? Can anyone point me to information on this?
(select @invtid = coalesce(@invtid + ',',' ')+rtrim(RoleID)
FROM (
Select distinct roleid
from UserAccounts
WHERE CustID = @custID
)
x)
Thanks.