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 stored by the msdb? : sql server database administration
How to drop existing indexes in ms sql server?
Define cross join in sql server joins?
What is the difference between varchar and nvarchar?
What are the restrictions while creating batches in sql server?
you have developed an application which uses many stored procedures and triggers to update various tables users ocassionally get locking problems which tool is best suited to help you diagnose the problem? : Sql server administration
Can we insert data into a view?
what are the different stages of Report Processing?
What is the difference between functions and scalar functions?
Explain the characteristics of a transaction server for example atomicity, consistency, isolation, durability?
Explain about sql server login?
What are the different normalization forms?
Is truncate a dml command?
What is a mixed extent?
What is resource governor in sql server?