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 a schema in sql server 2005? Explain how to create a new schema in a database? : Sql server database administration
What does normalization do to data?
Can you explain how long are locks retained within the repeatable_read and serializable isolation levels, during a read operation with row-level locking?
What is primary key, unique key, and foreign key?
What the different components of Replication and what is their use?
Can group functions be mixed with non-group selection fields in ms sql server?
How to find the version of sql server? : sql server database administration
How to use linked server?
What are distributed partitioned views?
you want to be sure that queries in a database always execute at the maximum possible speed. To achieve this goal you have created various indexes on tables which other statement will keep the database in good condition? : Sql server administration
How do you improve the performance of a SQL Azure Database?
What happens when the SQL Azure database reaches Max Size?
What are the lambda triggers?
What is the difference between Normalization and De-normalization?
you accidentally delete the msdb database what effect does this have on your existing sql databases, and how do you recover? : Sql server administration