Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 How to convert vertical to horizontal row

Author  Topic 

zubamark
Starting Member

23 Posts

Posted - 2008-06-13 : 15:55:42
id name
--- -----------------
236 SERVICE REQUEST
236 HARDWARE
236 Desktop
336 Loan

id name
-- ----------------------------
236 SERVICE REQUEST/ HARDWARE/ Desktop/Laptop/ Loan

chiragkhabaria
Master Smack Fu Yak Hacker

1907 Posts

Posted - 2008-06-13 : 16:22:21
you would like to check this one....

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=104746

Chirag

http://www.chirikworld.com
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-06-14 : 00:51:10
[code]SELECT t.id,LEFT(nl.namelist,LEN(nl.namelist)-1) AS name
FROM (SELECT DISTINCT id FROM YourTable) t
CROSS APPLY (SELECT name + '/' AS [text()]
FROM YourTable
WHERE id=t.id
FOR XML PATH(''))nl(namelist)[/code]
Go to Top of Page

zubamark
Starting Member

23 Posts

Posted - 2008-06-16 : 10:43:28
It works only with 1 id, but I need to have multiple ids.
Go to Top of Page

zubamark
Starting Member

23 Posts

Posted - 2008-06-16 : 10:45:14
This is SQL SERVER 2000 and XML PATH is no good.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-06-16 : 10:53:05
quote:
Originally posted by zubamark

This is SQL SERVER 2000 and XML PATH is no good.


Thenn you should have posted your question at SQL Server 2000 forum

Refer http://sqlblog.com/blogs/adam_machanic/archive/2006/07/12/rowset-string-concatenation-which-method-is-best.aspx

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -