CLEAR & RESET DATA FROM TABLES
-- =======================================
-- TRUNCATE STATEMENTS: Clear data from various tables
-- =======================================
-- This section truncates all the tables listed below.
-- Truncating is faster than deleting and resets the table without logging individual row deletions.
-- It does not fire any DELETE triggers and is irreversible unless wrapped in a transaction.
-- Be sure to verify that the data in these tables should be completely removed before executing this.
-- =======================================
TRUNCATE TABLE [Adjustments];
TRUNCATE TABLE [AlternateSKU];
TRUNCATE TABLE [Appointments];
TRUNCATE TABLE [Audit];
TRUNCATE TABLE [AuthPurchaser];
TRUNCATE TABLE [Bank];
TRUNCATE TABLE [Bank_Checks];
TRUNCATE TABLE [Bank_Checks_Bank];
TRUNCATE TABLE [Bank_Recon];
TRUNCATE TABLE [BatchSettle];
TRUNCATE TABLE [BeverageCode];
TRUNCATE TABLE [BillingInvoices];
TRUNCATE TABLE [BillingPayments];
TRUNCATE TABLE [BillingReminder];
TRUNCATE TABLE [BioMetric];
TRUNCATE TABLE [BuyDown];
TRUNCATE TABLE [CanceledInvoices];
TRUNCATE TABLE [CanceledItems];
TRUNCATE TABLE [CaseSku];
TRUNCATE TABLE [CashierMonitoring];
TRUNCATE TABLE [CDTFA_F];
TRUNCATE TABLE [CheckFile];
TRUNCATE TABLE [Checkout];
TRUNCATE TABLE [Checks];
TRUNCATE TABLE [ChecksDetails];
TRUNCATE TABLE [ClockIn];
TRUNCATE TABLE [CloseDaydate];
TRUNCATE TABLE [CreditCard];
TRUNCATE TABLE [CreditConfig];
TRUNCATE TABLE [Customer_Ledger];
TRUNCATE TABLE [DailyDeal];
TRUNCATE TABLE [DailyNumber];
TRUNCATE TABLE [DandHOrder];
TRUNCATE TABLE [Delivery];
TRUNCATE TABLE [Discontinued_items];
TRUNCATE TABLE [DiscountDescription];
TRUNCATE TABLE [DiscountDetail];
TRUNCATE TABLE [DriveThru];
TRUNCATE TABLE [FeaturedItems];
TRUNCATE TABLE [FieldPro_Details];
TRUNCATE TABLE [FieldPro_Main];
TRUNCATE TABLE [FinancialOperation];
TRUNCATE TABLE [GiftCard];
TRUNCATE TABLE [GiftCardTrans];
TRUNCATE TABLE [HandHeld_NewItems];
TRUNCATE TABLE [HandHeld_NewPrices];
TRUNCATE TABLE [Invoices];
TRUNCATE TABLE [InvoiceDetails];
TRUNCATE TABLE [ItemMessages];
TRUNCATE TABLE [KDS];
TRUNCATE TABLE [Kit];
TRUNCATE TABLE [Labels];
TRUNCATE TABLE [Labels_Food_Batch];
TRUNCATE TABLE [Labels_Food_Cat];
TRUNCATE TABLE [Layaway];
TRUNCATE TABLE [LayawayDetails];
TRUNCATE TABLE [LayawayPayments];
TRUNCATE TABLE [LayawaySetup];
TRUNCATE TABLE [LiveCashierData];
TRUNCATE TABLE [Locks];
TRUNCATE TABLE [LotMatrix];
TRUNCATE TABLE [MercuryBatchSum];
TRUNCATE TABLE [Messages];
TRUNCATE TABLE [MixandMatch];
TRUNCATE TABLE [NoSale];
TRUNCATE TABLE [OfflineTables];
TRUNCATE TABLE [OldPasswords];
TRUNCATE TABLE [OnlineOrderDetails];
TRUNCATE TABLE [OnlineOrderMain];
TRUNCATE TABLE [Open_Shift];
TRUNCATE TABLE [OrderList];
TRUNCATE TABLE [PONumbers];
TRUNCATE TABLE [PriceChangeHistory];
TRUNCATE TABLE [PriceGroup];
TRUNCATE TABLE [Printed];
TRUNCATE TABLE [Pull];
TRUNCATE TABLE [PurchaseOrder];
TRUNCATE TABLE [PurchaseOrderDetails];
TRUNCATE TABLE [Receiving];
TRUNCATE TABLE [Receiving_Items];
TRUNCATE TABLE [RemovedItems];
TRUNCATE TABLE [ReportDates];
TRUNCATE TABLE [ROA];
TRUNCATE TABLE [SalesReps];
TRUNCATE TABLE [Schedule];
TRUNCATE TABLE [SecurityOverideLog];
TRUNCATE TABLE [Serial];
TRUNCATE TABLE [ServiceDept];
TRUNCATE TABLE [ServiceDept1];
TRUNCATE TABLE [ServiceDeptCheckList];
TRUNCATE TABLE [ServiceDeptDiagCodes];
TRUNCATE TABLE [ServiceDeptDiagnostic];
TRUNCATE TABLE [ShipPay];
TRUNCATE TABLE [ShippingLabel];
TRUNCATE TABLE [SlideShow];
TRUNCATE TABLE [SubMenu2];
TRUNCATE TABLE [TableLayout];
TRUNCATE TABLE [TableLayoutSections];
TRUNCATE TABLE [TerminalMessage];
TRUNCATE TABLE [TicketSystem];
TRUNCATE TABLE [TicketSystemDetail];
TRUNCATE TABLE [TicketSystemStatus];
TRUNCATE TABLE [TimeClock];
TRUNCATE TABLE [WebNewCustomerForm];
TRUNCATE TABLE [Weborder_Details];
TRUNCATE TABLE [Weborder_Main];
TRUNCATE TABLE [WorkOrder];
TRUNCATE TABLE [WorkOrder_Mobile];
TRUNCATE TABLE [WorkOrderDetails];
TRUNCATE TABLE [WorkOrderDetails_Mobile];
TRUNCATE TABLE [YTD_Sales];
-- =======================================
-- COMMENTED-OUT TRUNCATE STATEMENTS: Tables intentionally excluded from truncation
-- =======================================
-- The following tables have been intentionally excluded from truncation for specific reasons.
-- Uncomment these if necessary, and ensure their inclusion aligns with the data reset logic.
-- =======================================
-- TRUNCATE TABLE [biochecks_CheckMaintanance]; -- Excluded due to unknown requirement
-- TRUNCATE TABLE [biochecks_CustData]; -- Excluded due to unknown requirement
-- TRUNCATE TABLE [biochecks_DetailsAmounts]; -- Excluded due to unknown requirement
-- TRUNCATE TABLE [Category]; -- This table is excluded. Confirm if required.
-- TRUNCATE TABLE [ReturnCode]; -- This table is excluded. Confirm if required.
-- TRUNCATE TABLE [Vendor_Backoffice]; -- This table is excluded. Verify necessity.
-- TRUNCATE TABLE [Vendors]; -- This table is excluded. Verify necessity.
-- =======================================
-- RESET INVENTORY DATA: Updating default values in the [Inventory] table
-- =======================================
-- These UPDATE statements reset various fields in the [Inventory] table to default values.
-- All price-related fields, costs, and quantities are set to '0' to reset the inventory data.
-- Any null or empty values are replaced by default values to ensure consistency and correctness in inventory data.
-- =======================================
UPDATE [Inventory] SET [Price] = '0';
UPDATE [Inventory] SET [PriceTwo] = '0';
UPDATE [Inventory] SET [PriceThree] = '0';
UPDATE [Inventory] SET [PriceFour] = '0';
UPDATE [Inventory] SET [PriceFive] = '0';
UPDATE [Inventory] SET [PriceSix] = '0';
UPDATE [Inventory] SET [PriceSeven] = '0';
UPDATE [Inventory] SET [PriceEight] = '0';
UPDATE [Inventory] SET [PriceNine] = '0';
UPDATE [Inventory] SET [PriceTen] = '0';
UPDATE [Inventory] SET [Cost] = '0';
UPDATE [Inventory] SET [Cost2] = '0';
UPDATE [Inventory] SET [AVGCost] = '0';
-- =======================================
-- RESET INVENTORY COUNT: Set the OnHand quantity to '0'
-- =======================================
-- The [OnHand] field is updated to '0' to reset the current inventory count for all items.
-- =======================================
UPDATE [Inventory] SET [OnHand] = '0';
-- =======================================
-- RESET OTHER FIELDS IN INVENTORY
-- =======================================
-- This section updates fields related to pricing, promotional data, and other inventory-specific details.
-- It ensures any invalid or missing values are corrected by replacing them with default values.
-- =======================================
UPDATE [Inventory] SET [PriceGroup] = NULL WHERE [PriceGroup] = '';
UPDATE [Inventory] SET [PromoPrice] = '0';
UPDATE [Inventory] SET [UsePromo] = '0';
UPDATE [Inventory] SET [UseMixandMatch] = '0';
UPDATE [Inventory] SET [MixandMatchID] = NULL;
UPDATE [Inventory] SET [UseHappyHour] = '0';
-- Ensures any SKU inconsistencies are corrected
UPDATE [Inventory] SET [SKU] = UPCCode WHERE [SKU] IS NULL;
UPDATE [Inventory] SET [ItemType] = 'Standard' WHERE [ItemType] = '';
-- Resets the availability of items by marking them as not discontinued
UPDATE [Inventory] SET [Discontinued] = '0';
-- =======================================
-- RESET IMAGE FIELDS IN INVENTORY (Optional)
-- =======================================
-- These fields are set to NULL to prevent large image files from affecting performance.
-- This is useful if new images are to be used or if the server is being optimized for performance.
-- Uncomment these lines if you want to retain existing image data; otherwise, leave them commented out.
-- =======================================
UPDATE [Inventory] SET [Image] = NULL;
UPDATE [Inventory] SET [ImagePath] = NULL;
-- =======================================
-- RESET KEYBOARD SETTINGS
-- =======================================
-- Reset visual properties for the [Keyboard] settings, ensuring all custom formatting is cleared.
-- This sets the font style properties to default values.
-- =======================================
UPDATE [Keyboard] SET [Visible] = 'True';
UPDATE [Keyboard] SET [Text] = NULL;
UPDATE [Keyboard] SET [Bold] = 'True';
UPDATE [Keyboard] SET [Italic] = 'False';
UPDATE [Keyboard] SET [Strikeout] = 'False';
UPDATE [Keyboard] SET [Underline] = 'False';
UPDATE [Keyboard] SET [Size] = '8.25';
-- =======================================
-- RESET NCR KEY MAP SETTINGS
-- =======================================
-- Resets the keys properties in the [NCR_KeyMap] table.
-- Ensures the flags for department, tender, and other key properties are cleared to their default states.
-- =======================================
UPDATE [NCR_KeyMap] SET [is_dept] = 'False';
UPDATE [NCR_KeyMap] SET [is_tender] = 'False';
UPDATE [NCR_KeyMap] SET [is_amount] = 'False';
UPDATE [NCR_KeyMap] SET [txtupc] = NULL;
UPDATE [NCR_KeyMap] SET [tender] = NULL;
UPDATE [NCR_KeyMap] SET [amount] = '0';
Last updated