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 is the difference between Clustered and Non-Clustered Index?
Are there any preferred steps that need to be taken care of before starting the installation of sql server 2000?
What are alternate keys?
What do you understand by replication in sql server?
What is the Disadvantage of indexed sequential file.
How to include text values in sql statements?
How to get the number of affected rows?
Explain cross join or cartesian product in sql?
What is default constraint?
Explain transaction server isolation?
What is normalization? Describe its different types.
what information is maintained within the msdb database? : Sql server administration
Ms sql server index?
what are the different ways to return the rowcount of a table?
What is query cost in sql server?