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 |
|
yakoo
Constraint Violating Yak Guru
312 Posts |
Posted - 2001-11-06 : 13:39:20
|
I have a situation where I need to either update or insert records from one table into another.I saw a post from nr that I believe should do the trickquote: create table #a (partID int)insert #a select PartID from products where bikeId = @bikeIDbegin tranupdate shopping_cartItemsset partQty = partQty + 1from #awhere #a.partId = shopping_cartItems.partIdand shopping_cartItems.cartId = @cartIddelete #afrom shopping_cartItemswhere #a.partId = shopping_cartItems.partIdand shopping_cartItems.cartId = @cartIdinsert shopping_cartItemsselect ...from #acommit tran
I was just wondering if anyone knew how fast and efficient this query was. Right now the data I have is small but in the future it will be rather large. Another thing to point out is that this will be executed within a DTS Package on 15 other tables also.Does anyone else have any suggestions on how to complete this task? |
|
|
|
|
|