"usp_SetShoppingCartID" Stored Procedure

Description:

This stored procedure migrates entries from a temporary shopping cart to a new CartID.  It is called on the component layer when a customer logs in or registers.

Definition:
CREATE Procedure usp_SetShoppingCartID
(
    @OriginalCartId nvarchar(50),
    @NewCartId      nvarchar(50)
)
AS

UPDATE 
    Sales.ShoppingCartItem
    
SET 
    ShoppingCartID = @NewCartId 
    
WHERE 
    ShoppingCartID = @OriginalCartId;

Database Tables Used:

ShoppingCartItem:   The ShoppingCartItem table keeps track of the items a user has purchased.  Its primary key is the ShoppingCartItemID field.  The ShoppingCartID is a string which is used to identify the user who owns the basket of items.  There is a many to one relationship between the ShoppingCartItem table and the Product table.  Note that if not Quantity is supplied, a default of 1 is entered.