Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

What are the advantages of mirroring?

970


What is a constant or literal in ms sql server?

1026


What is provisioning, billing and metering, and connection routing concepts in the service layer?

113


When would you use a before or after trigger?

892


What is wrong with sql server client libarary dll, ntwdblib.dll?

1030


What is the difference between ‘having’ clause and a ‘where’ clause?

1028


What sql server means?

952


What happens when transaction log is full?

909


What are the Advantages of using CTE in sql server?

1095


What are out-of-range errors with date and time literals?

1014


What is an sql server agent?

1042


Tell me what is fill factor?

944


What is the data tier application?

169


Can we insert data into a view?

1118


How to convert numeric expression data types using the cast() function?

1046