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)
 Update Query

Author  Topic 

doggi3
Yak Posting Veteran

62 Posts

Posted - 2004-09-14 : 06:06:35
Hi, I will like some advise on update query.

I have Column_A and Column_B in Table_1. I will like to append data from Column_A to Column_B.

From

Column_A | Column_B
A | B

To

Column_A | Column_B

| B A

In the result, Column_A becomes null.

I wrote a query like this:

Update Column_B + Column_A
From Table_1
Where Column_A <> ""

There is error with the query and I am sure the first sentence is wrong. However, I do not know how to append the data from the Column_A to Column_B.

Can any kind-hearted help? Thank you!

- HELP -

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2004-09-14 : 06:23:10
Update Table_1
set Column_B = Column_B + Column_A
Where Column_A is not null

Something like that maybe?? Although Column_A will still have the original value in...
Go to Top of Page

doggi3
Yak Posting Veteran

62 Posts

Posted - 2004-09-14 : 06:24:51
Thank you so much!

Can I set Column_A to null at the same time, in a single query?

Or do I write another query?

- HELP -
Go to Top of Page

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2004-09-14 : 06:38:13
You can do it in a single query...

Update Table_1
set Column_B = Column_B + Column_A, Column_A = null
Where Column_A is not null
Go to Top of Page

doggi3
Yak Posting Veteran

62 Posts

Posted - 2004-09-14 : 10:54:07
Thank You So Much~ ^-^

- HELP -
Go to Top of Page
   

- Advertisement -