Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMicrosoft SQL Server

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old August 28th, 2004, 01:07 PM
doggi3 doggi3 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 1 doggi3 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Exclamation Update Query

The original comment:

I have Tables A and B

Table_A:
+--------+-----------+
| Cust_ID| Name
| 1 | Mark |
| 2 | Jane |
| 3 | James |
|+-------+-----------+

Table_B:
+--------+---------------------+
| Cust_ID| Email |
| 1 | mark@yahoo.com |
| 2 | jane@hotmail.com |
| 3 | |
| | alex@hotmail.com |
+--------+--------------------+


I need to update Table_A with fields in Table_B with this result:

+--------+-----------+------------------+
| Cust_ID| Name | Email |
| 1 | Mark | mark@yahoo.com |
| 2 | Jane | jane@hotmail.com |
| 3 | James | |
| 4 | | alex@hotmail.com |
|+-------+-----------+------------------+

UPDATE TABLE_A LEFT JOIN TABLE_B ON TABLE_A.CUST_ID= TABLE_B.CUST_ID

I do not think this one will work. There seems to be some error with
it.

Also, my table A and B are very big in size. I am afraid system will
hang since there are over thousands of data. To prevent this, I will like to
add a column to Table B call 'Flag'. When the data is successfully
transfered, flag= 1. Else, flag= null. Hence this way, even if system
hangs, I am aware of what data is being transferred, what is not.

I do not think I can add an If-else statement in the SQL query. If so,
how
do I ensure that data is being transferred over before changing flag=
1?

Last edited by doggi3 : August 28th, 2004 at 01:16 PM. Reason: Error

Reply With Quote
  #2  
Old September 20th, 2004, 12:54 AM
Gururaj Gururaj is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 3 Gururaj User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
UPDATE & Joins!!

UPDATE TABLE_A LEFT JOIN TABLE_B ON TABLE_A.CUST_ID= TABLE_B.CUST_ID

How will this command work without a SET clause in it???

Create an email field in Table A which will b blank before updation.
Then use,


UPDATE TABLE_A SET TABLE_A .emailid = TABLE_b .emailid where TABLE_A.CUST_ID= TABLE_B.CUST_ID


Pls check the exact syntax . This should work .

gururaj0@yahoo.com

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMicrosoft SQL Server > Update Query


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT