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 an automatic checkpoint

552


What is model database? : SQL Server Architecture

559


what are the disadvantages of cursors? : Sql server database administration

488


What are the recovery models for a database?

607


What is a with(nolock)?

563






Explain about remote stored procedure?

580


What is for xml in sql server?

529


What are click through reports?

99


How to insert new line characters into strings?

552


Explain error handling in ssis?

559


If you're given a raw data table, how would perform etl (extract, transform, load) with sql to obtain the data in a desired format?

543


What are the events recorded in a transaction log?

494


How much is a sql server license?

496


What is forward - only cursors / read only cursor?

512


what are the important architecture components of SSRS?

92