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 is the difference between Clustered and Non-Clustered Index?

1051


Are there any preferred steps that need to be taken care of before starting the installation of sql server 2000?

986


What are alternate keys?

976


What do you understand by replication in sql server?

1055


What is the Disadvantage of indexed sequential file.

1076


How to include text values in sql statements?

1029


How to get the number of affected rows?

996


Explain cross join or cartesian product in sql?

882


What is default constraint?

991


Explain transaction server isolation?

1019


What is normalization? Describe its different types.

1096


what information is maintained within the msdb database? : Sql server administration

960


Ms sql server index?

1060


what are the different ways to return the rowcount of a table?

991


What is query cost in sql server?

986