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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Updating multiple rows

Author  Topic 

rlull
Starting Member

39 Posts

Posted - 2006-05-25 : 10:38:49
I have a Cart table and an OrderItems table. I need to update multiple rows in the OrderItems table based on the Product IDs in the Cart. I know I am close but haven't quite got it. Using the following SQL I am able to update a single row but if multiple products exist in the Cart, it errs out because the subquery finds multiple records. Thanks for any help.

(@CartID char(36), @OriginalOrderID int)


/* Update order items */
update OrderItems
set
BackOrdered = 0,
BOShipped = 1,
BOShipDate = GetDate(),
BackOrderID = OrderID
where OrderID = @OriginalOrderID
and ProdID = (select ProdID from Cart where CartID = @CartID)

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2006-05-25 : 14:06:03
ProdID IN (select ProdID from Cart where CartID = @CartID)


Tara Kizer
aka tduggan
Go to Top of Page

rlull
Starting Member

39 Posts

Posted - 2006-05-25 : 14:41:59
Worked perfectly, thanks!
Go to Top of Page
   

- Advertisement -