How to get the row values as comma separated by a query

Showing Answers 1 - 14 of 14 Answers

vinod.km

  • May 16th, 2008
 

What I understood from your question  is that you want  to comma seperate the values of a particular column for its  different rows. If this the question then query will be

DECLARE @SQL AS VARCHAR(500)

SELECT @SQL = ISNULL(@SQL,' ')+',' + ColumnName FROM TableName

SELECT @SQL


  Was this answer useful?  Yes

Mahesh

  • Aug 22nd, 2011
 

Used in 11G

Code
  1. span style="color: #ff0000;">','

  Was this answer useful?  Yes

rajesh kumar

  • Sep 7th, 2011
 

select row1||',',row2||',' ,row3 from table name;

  Was this answer useful?  Yes

rajesh kumar

  • Sep 7th, 2011
 

select COLUMN1||',' , COLUMN2||',' ,COLUMN3||',' from table name

  Was this answer useful?  Yes

NANNE SAHEB CHINTHALACHERUVU

  • Oct 4th, 2011
 

Code
  1. span style="color: #ff0000;">','

Raj

  • Nov 7th, 2011
 

Code
  1. span style="color: #ff0000;">','''','''


  Was this answer useful?  Yes

kranthi swaroop

  • Dec 3rd, 2011
 

Kindly elobrate your issue.

As per my concern you can use CONCAT or PIE ||

Example

Code
  1. span style="color: #ff0000;">','','

  Was this answer useful?  Yes

surendra kumar

  • May 8th, 2016
 

DECLARE @SQL AS VARCHAR(Max)
SELECT @SQL = coalesce(@SQL +;,)+Column Nmae from Table Name
print @SQL

  Was this answer useful?  Yes

Bikesh Srivastava

  • Aug 5th, 2016
 

Use this code to seprate row value in single coulmn

Code
  1. span style="font-style: italic;">--group by p.[Account ID],p.[Contact ID],p.[Account Name],p.[Email],p.[Contact Role]

  Was this answer useful?  Yes

punkaj

  • May 24th, 2017
 

using LISTAGG(colname) within group(order by col)

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions