468,133 Members | 1,315 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,133 developers. It's quick & easy.

Combine values

Hi,
Using SQL server, I need to update a field in table A with a combination of one or more values from the same column in table B.
Example:

A
Col1
field1

B
Col1
John
George
Paul
Ringo

The result in field1 could look like this: "George, Ringo".
(I will use a select statement to extract which rows from table B I want.)

This would have been easy if the values to be combined had been in a single row, but I don't know how to deal with fetching from a single column. How can I do this?

I'm not new to programming, just to SQL...

/Chrisbo
May 10 '07 #1
1 1334
Vidhura
99
Hope this helps

declare @abbr varchar(1000)

select @abbr=COALESCE(@abbr+ ',', '')+Col1 from B

select @abbr
May 14 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by laurenq uantrell | last post: by
3 posts views Thread by Schroeder, AJ | last post: by
20 posts views Thread by Steve London | last post: by
4 posts views Thread by ghjk | last post: by
8 posts views Thread by ghjk | last post: by
27 posts views Thread by didacticone | last post: by
1 post views Thread by gcdp | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.