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 / senthil kumar murugan
;WITH ABC (no, name) AS
(
SELECT 1, CAST('' AS VARCHAR(8000))
UNION ALL
SELECT B.no + 1, B.name + A.name + ', '
FROM (
SELECT Row_Number() OVER (ORDER BY no) AS no, name FROM
emp1) A
INNER JOIN ABC B ON A.no = B.no
)
SELECT TOP 1 name FROM ABC ORDER BY no DESC
Is This Answer Correct ? | 1 Yes | 2 No |
Post New Answer View All Answers
Is there any performance difference between if exists (select null from table) and if exists (select 1 from table)?
How to connect Azure federated root database and apply federation in entity framework?
Tell me what do we need queues in sql service broker?
Name 3 ways to get an accurate count of the number of records in a table?
How do I find the port number for sql server?
How to execute a sql statement using odbc_exec()?
Explain the different types of joins?
What is the new security features added in sql server 2014? : sql server security
How can you find out how many rows returned in a cursor?
What are subqueries in sql server?
what exactly sql injuction.how to overcome.....
What is checkpoint in sql server?
How can I know what locks are running on which resource?
Explain about analysis services?
how to overcome kernel isssues