--- BACKUP the Original SedonaOffice Database used for the new Company ---
--- RESTORE the New Company Database FROM the BACKUP and name it as a the *new desired company name* ---
--- Backup sedonamaster before making any changes ---
--- Add a line in Sedona Master, copying the line of the company that the backup was made from ---
--- Be sure to edit the Company name to the new company and DataSource to reflect the restored(new) database filename ---
--- Execute the script below against the new Comapny Dtatbase to remove old data. ---
--- BE SURE YOU ARE RUNNING THESE SCRIPTS AGAINST THE NEW COMPANY BEING CREATED ---
--- THESE SCRIPTS WILL RESULT IN LOSS OF DATA ---
delete AP_Check where Check_Id >1
Truncate table AP_Check_Expense
Truncate table AP_Check_Invoices
Truncate table AP_Check_Parts
Truncate table AP_Company_Aging
delete AP_Credit where Credit_Id > 1
Truncate table AP_Credit_Detail
Truncate table AP_Credit_Expense
Truncate table AP_Credit_Parts
delete AP_Invoice where Invoice_Id > 1
Truncate table AP_Invoice_Expense
Truncate table AP_Invoice_Parts
delete AP_Purchase_Order where Purchase_Order_Id > 1
Truncate table AP_Purchase_Order_Expense
Truncate table AP_Purchase_Order_Parts
Truncate table AP_Recurring
update AP_Vendor set Invoice_Balance = 0
update AP_Vendor set Credit_Balance = 0
update AP_Vendor set Current_Balance = 0
update AP_Vendor set Branch_Id = 2
update AP_Vendor_Accounts set Amount = 0
Truncate table AP_Vendor_Userdef
dbcc shrinkfile (security_log,2)
Truncate table AR_ACH
Truncate table AR_ACH_Batch
Truncate table AR_ACH_Created_By
Truncate table AR_ACH_Customer
Truncate table AR_ACH_Direct
Truncate table AR_ACH_Document
Truncate table AR_ACH_FTP_History
delete AR_ACH_Invoice where ACH_Invoice_Id > 1
dbcc shrinkfile (security_log,2)
delete AR_Advance_Deposit where Advance_Deposit_Id > 1
Truncate table AR_Advance_Deposit_Detail
delete AR_Bank where Bank_Id > 1
delete AR_Bill_Contact where Bill_Contact_Id > 1
delete AR_Branch where Branch_Id > 2
dbcc shrinkfile (security_log,2)
Update AR_Branch set Last_Cycle_Id = 1
Truncate table AR_Branch_RMR
delete AR_Cancel_Profile_Detail where Cancel_Profile_Detail_Id > 1
delete AR_Cancel_Queue where Cancel_Queue_Id > 1
dbcc shrinkfile (security_log,2)
delete AR_Cancel_Queue_Detail where Cancel_Queue_Detail_Id > 1
delete AR_Cancel_Queue_Site where Cancel_Queue_Site_Id > 1
Truncate table AR_Check_21_Layout_Type
Truncate table AR_Collection_Branch
dbcc shrinkfile (security_log,2)
delete AR_Collection_Event where Collection_Event_Id > 1
delete AR_Collection_Notes where Collection_Notes_Id > 1
delete AR_Collection_Profile where Collection_Profile_Id > 1
delete AR_Collection_Queue where Collection_Queue_Id > 1
Truncate table AR_Company_RMR
dbcc shrinkfile (security_log,2)
Truncate table AR_Company_Setup
delete AR_Credit where Credit_Id > 1
Truncate table AR_Credit_Auto
delete AR_Credit_Detail where Credit_Detail_Id > 1
Truncate table AR_Credit_Item
dbcc shrinkfile (security_log,2)
Truncate table AR_Credit_Item_Tax
Truncate table AR_Credit_Request
delete AR_Customer where Customer_Id > 1
delete AR_Customer_Aging where Customer_Aging_Id > 1
Truncate table AR_Customer_Aging_Invoice
dbcc shrinkfile (security_log,2)
Truncate table AR_Customer_Aging_RetroActive
Truncate table AR_Customer_Bank
delete AR_Customer_Bill where Customer_Bill_Id > 1
delete AR_Customer_Bill_Aging where Customer_Bill_Aging_Id > 1
Truncate table AR_Customer_CC
dbcc shrinkfile (security_log,2)
delete AR_Customer_Contact where Customer_Contact_Id > 1
Truncate table AR_Customer_EFT
delete AR_Customer_Equipment where Customer_Equipment_Id > 1
delete AR_Customer_Group where Customer_Group_Id > 1
Truncate table AR_Customer_Item
dbcc shrinkfile (security_log,2)
Truncate table AR_Customer_Late_Fees
Truncate table AR_Customer_Master_Item
delete AR_Customer_Notes where Customer_Notes_Id > 1
delete AR_Customer_Recurring where Customer_Recurring_Id > 1
delete AR_Customer_Relation where Customer_Relation_Id > 1
dbcc shrinkfile (security_log,2)
delete AR_Customer_Site where Customer_Site_Id > 1
Truncate table AR_Customer_Site_Item
delete AR_Customer_Site_Userdef where Customer_Site_Userdef_Id > 1
delete AR_Customer_System where Customer_System_Id > 1
Truncate table AR_Customer_System_Userdef
dbcc shrinkfile (security_log,2)
delete AR_Cycle where Cycle_Id > 1
Truncate table AR_Cycle_Branches
Truncate table AR_Cycle_Customer
Truncate table AR_Cycle_Deferred_Income
Truncate table AR_Cycle_Detail
Truncate table AR_Cycle_Distribution
dbcc shrinkfile (security_log,2)
Truncate table AR_Cycle_Royalty
Truncate table AR_Cycle_Tax
delete AR_Dealer where Dealer_ID > 1
Truncate table AR_Dealer_Customers
delete AR_Deposit where Deposit_Id > 1
dbcc shrinkfile (security_log,2)
delete AR_Deposit_Batch where Deposit_Batch_Id > 1
delete AR_Deposit_Check where Deposit_Check_Id > 1
delete AR_Deposit_Check_Detail where Deposit_Check_Detail_Id > 1
delete AR_Deposit_Register where Deposit_Register_Id > 1
delete AR_EFT where EFT_Id > 1
dbcc shrinkfile (security_log,2)
delete AR_EFT_Invoices where EFT_Invoices_Id > 1
delete AR_Invoice where Invoice_Id > 1
Truncate table AR_Invoice_Credit
Truncate table AR_Invoice_Item
Truncate table AR_Invoice_Item_Tax
dbcc shrinkfile (security_log,2)
Truncate table AR_Invoice_Print
Truncate table AR_Invoice_Print_Queue
Truncate table AR_Invoice_Royalty
delete AR_Master_Account where Master_Account_Id > 1
Truncate table AR_Master_Account_Services
dbcc shrinkfile (security_log,2)
Truncate table AR_Rate_Increase
Truncate table AR_Rate_Increase_Branch
Truncate table AR_Rate_Increase_Customer
Truncate table AR_Rate_Increase_Item
Truncate table AR_Rate_Increase_Memo
dbcc shrinkfile (security_log,2)
Truncate table AR_Recurring_Royalty
Truncate table AR_RMR_Tracking
delete AR_Sales_Tax where Sales_Tax_Id > 1
update AR_Setup_Defaults set Branch_Id = 2
update AR_Setup_Processing set Next_Invoice = 100
dbcc shrinkfile (security_log,2)
update AR_Setup_Processing set Next_Customer_Number = 100
update AR_Setup_Processing set Next_Job_Number = 100
update AR_Setup_Statements set Minimum_Days = 31
delete AR_Site_Contact where Site_Contact_Id > 1
delete AR_Unapplied_Cash where Unapplied_Cash_Id > 1
dbcc shrinkfile (security_log,2)
Truncate table AR_Unapplied_Cash_Detail
delete AR_Userdef_1 where Userdef_1_Id > 1
delete AR_Userdef_2 where Userdef_2_Id > 1
delete AR_Userdef_3 where Userdef_3_Id > 1
delete AR_Userdef_4 where Userdef_4_Id > 1
dbcc shrinkfile (security_log,2)
delete AR_Userdef_5 where Userdef_5_Id > 1
Delete AR_Userdef_6 where Userdef_6_Id > 1
delete AR_Userdef_7 where Userdef_7_Id > 1
delete AR_Userdef_8 where Userdef_8_Id > 1
delete AR_Userdef_9 where Userdef_9_Id > 1
dbcc shrinkfile (security_log,2)
Truncate table CS_Alarm_Company_Service
Truncate table CS_Customer_Monitoring
Truncate table CS_Customer_System
dbcc shrinkfile (security_log,2)
Truncate table CS_Customer_System_Access_Card
Truncate table CS_Customer_System_Call_List
Truncate table CS_Customer_System_Instruction
Truncate table CS_Customer_System_Schedule
Truncate table CS_Customer_System_Test
dbcc shrinkfile (security_log,2)
Truncate table CS_Customer_System_Zone
update CS_Setup set Alarm_Company_Id = 1 where Setup_Id = 1
Truncate table IN_Cost_Layer
update IN_Inventory set On_Hand_New = 0
update IN_Inventory set On_Hand_Used = 0
update IN_Inventory set Committed_Quantity = 0
update IN_Inventory set On_Order_Quantity = 0
dbcc shrinkfile (security_log,2)
update IN_Inventory set Maximum_Qty = 0
update IN_Inventory set Value_On_Hand = 0
update IN_Inventory set Standard_Cost = 0
Truncate table IN_Inventory_Serial_Part
Truncate table IN_Journal
dbcc shrinkfile (security_log,2)
Truncate table IN_Material_Handler_Warehouses
delete IN_Physical where Physical_Id > 1
dbcc shrinkfile (security_log,2)
Truncate table IN_Physical_Part
Truncate table IN_Physical_Part_Count
delete IN_Receipt where Receipt_Id > 1
Truncate table IN_Receipt_Expense
dbcc shrinkfile (security_log,2)
Truncate table IN_Receipt_Parts
delete IN_Repair_Order where Repair_Order_Id > 1
Truncate table IN_Repair_Order_Expense
Truncate table IN_Repair_Order_Parts
Truncate table IN_Requisition
dbcc shrinkfile (security_log,2)
Truncate table IN_Requisition_Parts
delete IN_Transfer where Transfer_Id > 1
delete IN_Warehouse where Warehouse_Id > 2
update IN_Warehouse set Warehouse_Code = 'Main' where Warehouse_Id = 2
update IN_Warehouse set Description = 'Main' where Warehouse_Id = 2
dbcc shrinkfile (security_log,2)
update IN_Warehouse set Branch_Id = 2 where Warehouse_Id = 2
Truncate table IO_Message
delete OE_Contact where Contact_id > 1
delete OE_Install_Company where Install_Company_Id > 2
delete OE_Job where Job_Id > 1
dbcc shrinkfile (security_log,2)
Truncate table OE_Job_Approval
delete OE_Job_Commission where Job_Commission_Id > 1
delete OE_Job_Dispatch where Dispatch_Id > 1
delete OE_Job_Install where Job_Install_Id > 1
delete OE_Job_Issue where Job_Issue_Id > 1
dbcc shrinkfile (security_log,2)
delete OE_Job_Issue_Part where Job_Issue_Part_Id > 1
Truncate table OE_Job_Labor_Task
delete OE_Job_Log where Job_Log_Id > 1
delete OE_Job_Notes where Job_Notes_Id > 1
delete OE_Job_Parts where Job_Part_Id > 1
dbcc shrinkfile (security_log,2)
Truncate table OE_Job_Parts_Est
delete OE_Job_Recurring where Job_Recurring_Id > 1
delete OE_Job_Schedule where Job_Schedule_Id > 1
delete OE_Job_System where Job_System_Id > 1
delete OE_Job_Task where Job_Task_Id > 1
dbcc shrinkfile (security_log,2)
delete OE_Job_TimeSheet where Job_TimeSheet_Id > 1
delete OE_Job_TS_Batch where TS_Batch_id > 1
delete OE_Job_TS_Batch_Entry where TS_Batch_Entry_id > 1
Truncate table OE_Job_Type_Account
Truncate table OE_Job_Type_Commission_Type
dbcc shrinkfile (security_log,2)
Truncate table OE_Job_UserDef
delete OE_Prospect where Prospect_id > 1
Truncate table OE_Prospect_Notes
delete PR_Batch where Batch_Id > 1
delete SM_Contact where Contact_Id > 1
dbcc shrinkfile (security_log,2)
delete SM_Opportunity where Opportunity_Id > 1
Truncate table SM_Opportunity_Items
Truncate table SM_Opportunity_Parts
delete SM_Prospect where Prospect_id > 1
delete SM_Prospect_Contact where Contact_id > 1
dbcc shrinkfile (security_log,2)
delete SM_Prospect_Notes where Prospect_Note_id > 1
delete SM_Prospect_UserDef where User_Def_Id > 1
Truncate table SS_LockTable
delete SV_Inspection where Inspection_Id > 1
update SV_Inspection set Service_Level_Id = 1 where Inspection_ID = 1
Truncate table SV_Inspection_Parts
dbcc shrinkfile (security_log,2)
delete SV_Service_Company where Service_Company_Id > 2
update SV_Service_Tech set Service_Company_Id = 2
update SV_Service_Tech set Warehouse_Id = 2
update SV_Service_Tech set Install_Company_id = 2
delete SV_Service_Ticket where Service_Ticket_Id > 1
dbcc shrinkfile (security_log,2)
Truncate table SV_Service_Ticket_Dispatch
Truncate table SV_Service_Ticket_History
delete SV_Service_Ticket_Notes where Service_Ticket_Notes_Id > 1
Truncate table SV_Service_Ticket_Other
Truncate table SV_Service_Ticket_Parts
dbcc shrinkfile (security_log,2)
update SV_Setup set Next_Ticket_Number = 1000
delete SV_Tech_Absence where Tech_Absence_Id > 1
Truncate table SV_Ticket_Systems
Truncate table SV_Ticket_Userdef
Truncate table SY_Critical_Message
dbcc shrinkfile (security_log,2)
Truncate table SY_Edit_Log
update SY_Employee set Branch_Id = 2
Truncate table SY_ErrorLog
update GL_Account set Current_Balance = 0
update GL_Account set Last_Ending_Balance = 0
dbcc shrinkfile (security_log,2)
delete GL_Account_Fiscal_Balance where Balance_Id > 2
delete GL_Account_Period where Account_Period_Id > 1
delete GL_Account_Period_Branch where Account_Period_Branch_Id > 1
delete GL_Account_Period_Category where Account_Period_Category_Id > 1
Truncate table GL_Account_Reconcile
delete GL_Accounting_Period where Accounting_Period_ID > 1
dbcc shrinkfile (security_log,2)
Truncate table GL_Accrued_Commission
delete GL_Book where Book_Id > 1
delete GL_Deferred_Income where Deferred_Income_Id > 1
Truncate table GL_Posting
Truncate table GL_Register
Truncate table GL_Journal_Template
Truncate table GL_Journal_Template_Detail
dbcc shrinkfile (security_log,2)
update GL_Setup set Current_Fiscal_Year = 2011
update GL_Setup set Next_Journal_Entry = 1
update GL_Setup set Current_Period_Id = 1
Delete from IN_Physical WHERE physical_id >1
Delete from IN_Physical_Part WHERE physical_id >1
Delete from IN_Physical_Part_Count
Delete from IN_Receipt WHERE receipt_id >1
Delete from IN_Receipt_Expense WHERE receipt_id >1
Delete from IN_Receipt_Parts WHERE receipt_id >1
Delete from IN_Repair_Order WHERE repair_order_id >1
Delete from IN_Repair_Order_Expense WHERE repair_order_id >1
Delete from IN_Repair_Order_Parts WHERE repair_order_id >1
Delete from IN_Transfer WHERE transfer_id >1
exec Reset_Totals
dbcc shrinkfile (security_log,2)