SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Update Query
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

doggi3
Yak Posting Veteran

62 Posts

Posted - 09/14/2004 :  06:06:35  Show Profile  Reply with Quote
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

United Kingdom
3603 Posts

Posted - 09/14/2004 :  06:23:10  Show Profile  Reply with Quote
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 - 09/14/2004 :  06:24:51  Show Profile  Reply with Quote
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

United Kingdom
3603 Posts

Posted - 09/14/2004 :  06:38:13  Show Profile  Reply with Quote
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 - 09/14/2004 :  10:54:07  Show Profile  Reply with Quote
Thank You So Much~ ^-^

- HELP -
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000