Link to home
Start Free TrialLog in
Avatar of conrad2010
conrad2010

asked on

T-SQL select output to string

what is the quickest way to have the resultset (multimple records, one field) of a SELECT statement be formatted into one string?
SELECT
   name
FROM
   tblCity
WHERE
   state = 'CA'

Open in new window

Avatar of Brad Howe
Brad Howe
Flag of Canada image

Can you clarify what you are trying to do?

I'm guess, you want the select multiple fields from a conditional select statement and have the returned result 1 string but your code snippet is confusing.

Let us know.
ASKER CERTIFIED SOLUTION
Avatar of Reza Rad
Reza Rad
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
another way:

SELECT 
                name+',' AS cities 
            FROM 
                tblCity
			WHERE
				state = 'CA'
            FOR XML PATH ('')

Open in new window