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

Explain what is the difference between a local and a global temporary table?

981


Explain the dirty pages?

984


How to read data in a table with "select" statements?

952


What is attribute hierarchy? : sql server analysis services, ssas

998


What is a linked server in sql server?

1053


When you use @@error and try-catch?

1028


Is a null value equal to anything? Can a space in a column be considered a null value? Why or why not?

1049


How to insert multiple rows with a subquery?

1107


Are there issues when exporting SSRS reports into Microsoft Excel? When my users are trying to export a SSRS report into Microsoft Excel, one or two columns in the report appear to merge together. Why might this be?

190


What are the types of normalization?

1013


How to create new tables with "select ... Into" statements in ms sql server?

973


what are defaults? : Sql server database administration

1069


What extended events?

991


Can we add an identity column to decimal datatype?

980


Describe the left outer join & right outer join. : sql server database administration

984