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.
| Author |
Topic |
|
help_needed
Starting Member
12 Posts |
Posted - 2009-02-08 : 12:59:37
|
| HiI need to update a table with data from another table and am trying to find out the best way to write it so it doesn't take days to complete due to the amount of records. The 1st table (vroll_2006) has approx 40,000,000 records and the 2nd (ctbands) has 26,000,000. I The table is linked by a column called addressurn and the one I want to update in the 1st table is called ctb. I have come up with the one below but not sure if this is the right way to go or not??update vroll_2006set ctb = ctbands.ctbfrom ctbands inner join vroll_2006 on vroll_2006.addressurn = ctbands.addressurnAny thoughts or help will be very appreciatedThanks |
|
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2009-02-08 : 13:07:50
|
Shouldn't it be like this? Also update in batches so you don't blow off the log file.Update Tset T.ctb = C.ctbfrom vroll_2006 Tinner join ctbands COn T.addressurn = C.addressurn |
 |
|
|
help_needed
Starting Member
12 Posts |
Posted - 2009-02-08 : 14:31:25
|
| Thanks for your help. How would you make it update in batches then? |
 |
|
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2009-02-08 : 16:25:04
|
| Did you search for it? Do you have Datetime column? |
 |
|
|
help_needed
Starting Member
12 Posts |
Posted - 2009-02-08 : 16:47:29
|
quote: Originally posted by sodeep Did you search for it? Do you have Datetime column?
No the only columns in vroll_2006 aretitle, forename, surname, address1, address2, town, county, postcode, addressurn, ctband in ctbands only 2 columns which areaddressurn, ctb |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-02-08 : 21:41:26
|
| whats the primary key of table? is there not an id column? |
 |
|
|
help_needed
Starting Member
12 Posts |
Posted - 2009-02-09 : 03:22:06
|
| The addressurn is a unique number for each address which is in both tables |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-02-09 : 03:28:55
|
| then split as batched based on addressurn values |
 |
|
|
|
|
|
|
|