I wanted to display a set of row results in a single Row or a single variable by comma seperated values in a SQL query.
DATA from a select statement is
NAME
-----
Alpha
Beta
Gaama
Need result in the manner of
Desired Result
Alpha,Beta,Gaama
The can be done by
DECLARE @strText varchar(Max)
SELECT @strText = COALESCE(@strText + ',', '') + CONTACT_NAME FROM table
SELECT @strText
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment
Express you views