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 generate create procedure script on an existing stored procedure?
What are cursors stored procedures and triggers?
Explain the third normal form(3nf)?
What were the latest updates to SQL Azure service?
Write a code to select distinct records without using the DISTINCT keyword.
Do you know what are acid properties of transaction?
Do you know what is lock escalation?
What is the architecture of ms sql reporting service?
Does any body please help me what question's have asked for SSRS in the interview?
Do you know what is difference between stored procedure and user defined function?
What is the order in which the sql query is executed?
What is SQL Azure Fabric?
What is Command line parameters in PLSQL.?
Explain about extended stored procedure?
Can you please explain the difference between primary keys and foreign keys?