there is a table having two columns no and name
and the data is
1 A
2 B
3 C

write a query that will result a horizontal output
A,B,C

Answer Posted / piyush sachan

DECLARE @List VARCHAR(8000)
SELECT @List = ISNULL(@List + ',', '') +names
FROM NewNew

SELECT @List

Orrrrrr

DECLARE @List VARCHAR(8000)
SELECT @List = COALESCE(@List + ',', '') +names
FROM NewNew

SELECT @List

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain in brief about Microsoft SQL server?

726


Define cursor locking

741


What are horizontal and vertical scaling?

166


What is the process of normalising?

752


What are character string data types in ms sql server?

796






What is normalization? Describe its different types.

767


you have a table with close to 100 million records recently, a huge amount of this data was updated now, various queries against this table have slowed down considerably what is the quickest option to remedy the situation? : Sql server administration

707


What are different types of join?

951


How to get a list of columns in a view using the "sp_columns" stored procedure?

792


What is the difference between index seek vs. Index scan?

771


What is sql server english query?

743


How to Update from select query in sql server?

732


What are the differences in Clustering in SQL Server 2005 and 2008 or 2008 R2?

764


Explain having clause?

727


Explain the difference between HTTP and HTTPS in database?

748