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 / utsav

declare @tst varchar(max)
set @tst=''
select @tst=@tst+col+',' from table
select @tst

there is a twist, if col contains any null value then this
query will return null. use isnull(col,'') in that case

Is This Answer Correct ?    5 Yes 1 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?

1059


Why normalization is used?

1013


What is data file in computer?

948


Explain “@@rowcount” and “@@error” in sql server?

1092


Write the SQL query to drop, truncate and delete table.

974


How to add the custom code in Report?

126


How can a database be repaired?

989


What is difference between equi join and natural join?

1041


What are the different types of indexes?

1119


What is the Control Flow in SSIS

1094


What are the types of database recovery models?

1126


What is data mart? : sql server analysis services, ssas

1056


Explain why variables called the most powerful component of ssis?

1102


What is BCNF? How is it better than 2NF & 3NF?

1018


how can you find out if the current user is a member of the specified microsoft® windows nt® group or microsoft sql server™ role? : Sql server administration

983