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 / soorai ganesh

Hi Friend,

If u use SQLSERVER 2005 u can try like this............

CREATE TABLE EMP ( ENAME VARCHAR(25))

INSERT INTO EMP VALUES('Ganesh')
INSERT INTO EMP VALUES('Narendra')
INSERT INTO EMP VALUES('Rinku')
INSERT INTO EMP VALUES('Selvam')
INSERT INTO EMP VALUES('Kirti')

SELECT REPLACE(REPLACE(
( SELECT ENAME AS EmpName FROM EMP FOR XML PATH ('') ) ,'<EmpName>',''),'</EmpName>',',')

Is This Answer Correct ?    6 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What keyword you will use to get schema appended to the result set of a ‘for xml’ query?

600


What is BLOCK statements in SQL?

803


What is the difference between left and right outer join?

540


Explain the properties of sub-query in sql server?

505


What are the differences between INNER JOIN, LEFT JOIN and RIGHT JOIN in SQL Server?

611






What is transaction server explicit transaction?

540


Are connections to sql server encrypted?

572


Which tcp/ip port does sql server run on? How can it be changed?

567


Explain the various types of concurrency problem. I.e. Lost or buried updates, uncommitted dependency, inconsistent analysis, phantom read?

499


Explain the steps needed to create a scheduled job?

523


How can we check the sql server version?

558


Where are SQL server users names and passwords are stored in sql server?

710


Explain the different types of joins?

566


What is difference between equi join and inner join?

480


If you lose rights to your sql server instance what are the options to connect to sql server instance? : sql server security

534