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 / rajesh.a

declare @res varchar(max)

set @res=''

select @res=@res+name+',' from table

select @res=substring(@res,1,len-1)

print @res

Is This Answer Correct ?    1 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the instances when triggers are appropriate?

719


How to add more data to the testing table in ms sql server?

737


Explain in brief how sql server enhances scalability of the database system?

686


What is an indexed view?

744


What is collation sensitivity?

715






Write a query to find 5th highest amount paid from the customer table.

701


What Are the Main Features of SQL Azure?

109


How to get nth highest salary from employee table.

793


What are the source of constraints?

665


What are the steps you will take to improve the performance of a poor performing query?

762


What are the reporting services components?

108


What do you mean by normalisation?

681


What are the benefits of filtered indexes?

711


How to create a large table with random data for index testing in ms sql server?

735


List the different types of collation sensitivities in sql server?

727