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 |
|
edburdo
Starting Member
1 Post |
Posted - 2006-02-28 : 09:36:08
|
| Here is what I am trying to accomplish.There are several tables. The primary table has a "sister" table in another database. I need to take some aggregated data from my first DB (call it DB1) and update respective records in DB2.Now, the fun part. I have to pull values from other tables before I can update (product descriptions and quantities and such). I also need to update existing records from DB1 to DB2, insert any missing records from DB1 to DB2 PROVIDED! those records have existing records over in DB2.ProductsNow, I have been using Update statements with subqueries to match. But, that updates all the records. When I only have 150 or so (normally) that is fine. But when I have 2 records to update out of 10,000, it takes forever. Is there a better approach? I thought about using a cursor (it will loop through 2 or 3 records to update). But I didn't know if there is a better way to update records based on values from another table.~ Eric |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-02-28 : 09:44:28
|
| The General Approach isUpdate T1set col=T2.colfrom Table1 T1 inner join Table2 T2on T1.UniqueCol=T2.UniqueColMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|