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 2000 Forums
 SQL Server Development (2000)
 merging multiple rows to one

Author  Topic 

akpaga
Constraint Violating Yak Guru

331 Posts

Posted - 2009-03-19 : 13:30:58
Hi i have two tables which on inner joining i get the
result as

saleman_id sales_task
234 clothes

234 accessories

234 kitchenry



how can i get this as one row in order to save row space.
ex in this way :234---- clothes,accessories,kitchenry

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-03-19 : 23:48:36
create userdefinedfunction to get this
see this link
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=121751
Go to Top of Page

Nageswar9
Aged Yak Warrior

600 Posts

Posted - 2009-03-21 : 08:20:56
[code]
Declare @TempTable Table
(
saleman_id INT,
sales_task VARCHAR(Max)
)
insert into @temptable select 234,'clothes'
insert into @temptable select 234,'accessories'
insert into @temptable select 234,'kitchenry'

Declare @str VARCHAR(Max) , @str1 VARCHAR(Max)
Select @str = '',@str1 = ''

Select @str = @str + ',' + sales_task from @TempTable where saleman_id = 234
Select @str1 = 234
select @str1,substring(@str,2,len(@str))
[/code]
Go to Top of Page
   

- Advertisement -