|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
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 |
![]() |
| Viewing: Dev Articles Community Forums > Databases > Microsoft SQL Server > Update Query |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|