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)
 Concatenate

Author  Topic 

callawayx14
Yak Posting Veteran

73 Posts

Posted - 2008-09-04 : 15:10:36
Hello,
I'm trying to concatenate two records in the same field
For example the results look like this

123 Dan
123 Bill

SELECT ID, NAME
FROM NAME
WHERE ID = '123'

I would like to see

123 Dan Bill

Bustaz Kool
Master Smack Fu Yak Hacker

1834 Posts

Posted - 2008-09-04 : 15:53:22
select a.ID, a.NAME + b.NAME
from NAME a
INNER JOIN NAME b
ON a.ID = B.ID
AND a.NAME > b.NAME

Do you care if DAN comes beford BILL or the other way around?


=======================================
It is impossible to imagine Goethe or Beethoven being good at billiards or golf. -H.L. Mencken, writer, editor, and critic (1880-1956)
Go to Top of Page

callawayx14
Yak Posting Veteran

73 Posts

Posted - 2008-09-04 : 17:16:44
Yes,it is important to be able to determine which will come first.

Thak you so much
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-09-05 : 03:33:43
What if there are more than two names for same id?

Madhivanan

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

callawayx14
Yak Posting Veteran

73 Posts

Posted - 2008-09-05 : 10:59:16
In this paticular situation, there would not be.

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-09-06 : 02:21:03
quote:
Originally posted by callawayx14

In this paticular situation, there would not be.




Well. Then go ahead with the given suggestion

Madhivanan

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

- Advertisement -