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...

hi,
i have a table called names and field name
select * from names
name
a
b
c
d

i want to display like this
name
a,b,c,d
how it is possible


Regards
Baiju

Answer Posted / gopi muluka

CREATE TABLE Names (Name VARCHAR(50))
GO
INSERT Names
SELECT 'A'
UNION
SELECT 'B'
UNION
SELECT 'C'
UNION
SELECT 'D'
GO

-- FIRST METHOD
DECLARE @Name VARCHAR(50)
SELECT @Name=ISNULL(@Name,'')+ COALESCE(Name,',')+',' FROM
Names
SELECT LEFT(@Name,LEN(@Name)-1)
GO
--SECOND METHOD
DECLARE @chrString as varchar(200)
SET @chrString=''
SELECT @chrString=@chrString + ',' + Name FROM Names

SELECT SUBSTRING(@chrString,2, LEN(@chrString))

GO
DROP TABLE Names

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the purpose of linked server configuration in sql server?

1036


What is trigger explain with program?

973


What is difference between order by and group by?

1000


Explain what is cte (common table expression)?

1119


What is "scheduled jobs" or "scheduled tasks"?

971


How many categories of data types used by sql server?

1010


What methods do you follow to protect from sql injection attack?

1014


what is denormalization? : Sql server database administration

920


Explain nested trigger in sql?

1063


What are the five characteristics of good data?

909


Explain syntax for dropping triggers?

923


Describe in brief databases and sql server databases architecture.

1004


Define magic tables in sql server?

1047


let's assume you have data that resides on sql server 6.5. You have to move it sql server 7.0. How are you going to do it? : Sql server database administration

946


how you can deploy an ssrs report?

178