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 |
|
link3228
Starting Member
1 Post |
Posted - 2003-05-12 : 19:47:37
|
| I am trying to import new records into a table. The SQL I used for the source file reads like this:Select Field1, Field2, Field3 from TableA T1 where Not Exists (Select * from TableB T2 Where T1.Field1 = T2.Field1 and T1.Field2 = T2.Field2)What is happending is the above SQL appears to place a shared page lock on the index for TableB. When the DTS process attempts to get an exclusive lock to do the Insert, the Process ID for the insert is blocked by the shared lock.My solution was to remove the check for existing records from the Input SQL and use a lookup table during the transformation and skip the row if it already exists.Can anyone suggest a better alternative.Thanks,John Shaening |
|
|
dsdeming
479 Posts |
Posted - 2003-05-13 : 08:19:45
|
| I haven't tested for locks, but what about using an outer join to find the new rows:SELECT T1.Field1, T1.Field2, T1.Field3 FROM TableA T1 LEFT OUTER JOIN TableB T2 ON T1.Field1 = T2.Field1 and T1.Field2 = T2.Field2WHERE T2.Field1 IS NULLHTH |
 |
|
|
|
|
|