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 is the difference between osql and query analyzer?

621


What are wait types?

663


Why does sql studio use a single registered database repository? : sql server management studio

603


What is normalization? Explain different forms of normalization?

616


What is filestream?

647






What is a rownum?

588


How to configure odbc dsn with different port numbers?

662


How important do you consider cursors or while loops for a transactional database?

611


What are synonyms?

623


What is subquery explain with example?

704


What is etl - extraction, transformation, and loading?

596


what are the reporting service components in SSRS?

120


How will you optimize a stored procedure optimization?

599


Define clusters?

723


What is a with(nolock)?

655