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
What are the advantages of mirroring?
What is a constant or literal in ms sql server?
What is provisioning, billing and metering, and connection routing concepts in the service layer?
When would you use a before or after trigger?
What is wrong with sql server client libarary dll, ntwdblib.dll?
What is the difference between ‘having’ clause and a ‘where’ clause?
What sql server means?
What happens when transaction log is full?
What are the Advantages of using CTE in sql server?
What are out-of-range errors with date and time literals?
What is an sql server agent?
Tell me what is fill factor?
What is the data tier application?
Can we insert data into a view?
How to convert numeric expression data types using the cast() function?