May 14, 2014 at 9:24 am
I have the following
DECLARE @NocMsg VARCHAR(MAX) = '';
SELECT @NocMsg += ISNULL(TD.RefNum + ' ', '')
FROM MyTable TD;
This should give me a list of RefNum values separated by spaces. It worked for my test but I wanted to know if I am missing something.
Is there a better way to do this?
Thank you,
May 14, 2014 at 10:16 am
That will work to get a single value. If you need several values/groups, you could read about it in the following article:
http://www.sqlservercentral.com/articles/comma+separated+list/71700/
May 14, 2014 at 10:24 am
Thanks!
Only one value is expected.
I was reviewing a developers code that had a cursor and thought my way would be better.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply