I have the following query:
SELECT
'' + CONVERT(VARCHAR(MAX),c.ClientId) + ','
FROM [dbo].[tblClient] c
This returns 17,000 + rows. Is there a way to make all these rows return as 1 value? For example:
6A7A24CD-061C-4653-9790-882D90F81E1D,0980722E-6E96-4498-B3BB-BFB4CA60EAC6,etc etc etc.
I am trying to use this as a parameter for testing.
does this work for you?
Note: Just be aware that if you add an ORDER BY that it is not guaranteed to sort it, in that case use xml path as shown in Remus’ answer
See also: Concatenate Values From Multiple Rows Into One Column Ordered