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
How to delete duplicate rows from table except one?
How to count rows with the count(*) function in ms sql server?
How do I find the size of a sql server database?
What is the maximum size per database for sql server express?
How to update values in a table with update statements in ms sql server?
Can sql servers link to other servers like oracle?
What are the different types of stored procedures?
What is the data type of time?
What is ssl in sql server?
What are the tables in sql?
What is bcnf normalization form?
Do you know what is sql service broker?
What is a collation?
What is the security principal at the server level that represents your session?
what is the difference between them (ethernet networks and token ring networks)? : Sql server database administration