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 is the difference between Clustered and Non-Clustered Index?
Why normalization is used?
What is data file in computer?
Explain “@@rowcount” and “@@error” in sql server?
Write the SQL query to drop, truncate and delete table.
How to add the custom code in Report?
How can a database be repaired?
What is difference between equi join and natural join?
What are the different types of indexes?
What is the Control Flow in SSIS
What are the types of database recovery models?
What is data mart? : sql server analysis services, ssas
Explain why variables called the most powerful component of ssis?
What is BCNF? How is it better than 2NF & 3NF?
how can you find out if the current user is a member of the specified microsoft® windows nt® group or microsoft sql server™ role? : Sql server administration