This stored procedure is run nightly by a scheduled SQL job called "RemoveAbandonedCarts." It deletes all entries in the ShoppingCart table that are more than one day old. Since the items in a shopping cart are move to the Orders and OrderDetails tables when an order is placed, only abandoned carts are removed.
Definition:CREATE Procedure ShoppingCartRemoveAbandoned AS DELETE FROM ShoppingCart WHERE DATEDIFF(dd, DateCreated, GetDate()) > 1Database 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.