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

List some advantages and disadvantages of stored procedure?

1014


You want to check the syntax of a complicated update sql statement without executing it. What command should you use?

975


What is the difference between having clause and where clause in sql server?

1090


What is an active database?

1004


How can we use ConnectorJ JDBC Driver with MS SQL?

993


What are sql azure firewall rules?

106


What is index, cluster index and nonclustered index?

990


How many files can a database contain in sql server?how many types of data files exists in sql server? How many of those files can exist for a single database?

1135


What is data file in computer?

939


Does full backup break log chain?

958


Stored Procedure returns data from multiple tables. How to access it in your ASP.Net code?

1053


What are the advantages of the mirroring?

1078


What is row_number () and partition by in sql server?

1075


What is SQL Server?

1201


How to create a local temporary stored procedure?

997