DECLARE @OrderNumber int,
@Sku char(9),
@Price decimal(16,2),
@Qty int
SELECT @OrderNumber = SCOPE_IDENTITY()
INSERT INTO [OrderLine]
([OrderNumber]
,[Sku]
,[Price]
,[Qty])
SELECT Sku, Price, Qty FROM dbo.CartItems WHERE UserID = @UserID
UPDATE S SET QtyOnHand = QtyOnHand - CI.Qty
FROM Skus S INNER JOIN dbo.CertItems CI ON S.Sku = CI.Sku
WHERE CI.UserID = @UserID
DELETE CartItems WHERE UserID = @UserID
|