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
What are the types of dml?
Explain for xml explicit mode?
How to return the second 5 rows in ms sql server?
What do you understand by hotfixes and patches in sql server?
What are system databases in ms sql server?
explain what is a schema in sql server 2005? Explain how to create a new schema in a database? : Sql server database administration
How to test subquery results with the exists operator?
What are different types of replication in sql server?
Why should we go for stored procedures? Why not direct queries?
What are null values in ms sql server?
What is cube dimension? : sql server analysis services, ssas
what's the difference between a primary key and a unique key? : Sql server database administration
can a database be shrunk with users active? : Sql server administration
What is service broker? : sql server database administration
What are trace files?