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 / utsav

declare @tst varchar(max)
set @tst=''
select @tst=@tst+col+',' from table
select @tst

there is a twist, if col contains any null value then this
query will return null. use isnull(col,'') in that case

Is This Answer Correct ?    5 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a data source or ds? : sql server analysis services, ssas

553


What is dirty page?

559


How to delete multiple rows with one delete statement in ms sql server?

509


Can we return Data from 4(more than 1) tables in stored procedure?

607


What is the meaning of sql server?

524






How to filter records of table in SQL SERVER?

590


How do we Backup SQL Azure Data?

86


Explain what is the function of sql server agent windows service?

538


mention different types of relationships in the dbms?

499


how to create “alternate row colour”?

109


How can I create a new template for import ? : sql server management studio

589


According to you what goes into making the best database administrator? : sql server database administration

539


How to modify the underlying query of an existing view?

527


What do you understand by recursive stored procedures?

561


Explain sql server service broker?

503