"ShoppingCartItemCount" Stored Procedure

Description:

This stored procedure returns a count of all the distinct products in a user's shopping cart.

Definition:

    CREATE Procedure ShoppingCartItemCount
    (
        @CartID    nvarchar(50),
        @ItemCount int OUTPUT
    )
    AS

    SELECT
        @ItemCount = COUNT(ProductID)

    FROM
        ShoppingCart

    WHERE
        CartID = @CartID
        
Database Tables Used:

ShoppingCart:   The ShoppingCart table keeps track of the items a user has purchased.  Its primary key is the RecordID field.  The CartID is a string which we use to identify the user currently logged in.  There is a many to one relationship between the ShoppingCart table and the Products table.  Note that if not Quantity is supplied, a default of 1 is entered.