Refresh Dates

From Bitnami MediaWiki
Jump to navigation Jump to search

begin declare @ltbl_diff table (valindex integer ,diff integer)

if (db_name () <> 'ShowNovus') begin raiserror ('Only run this script in a "Show" database',0,1) WITH NOWAIT end

begin transaction


Accounting_Period

delete @ltbl_diff

raiserror ('Accounting_Period 1 of 39',0,1) with nowait

insert @ltbl_diff select 1,datediff (month,max (date_from),getdate ()) from Accounting_Period insert @ltbl_diff select 2,datediff (month,max (date_to),getdate ()) from Accounting_Period

update Accounting_Period set date_from = case when date_from is not null then dateadd (month,(select diff from @ltbl_diff where valindex = 1),date_from) else date_from end ,date_to = case when date_to is not null then dateadd (month,(select diff from @ltbl_diff where valindex = 2),date_to) else date_to end ,updated_by = 'date_update' ,updated_on = getdate ()


AP_Apply

delete @ltbl_diff

raiserror ('AP_Apply 2 of 39',0,1) with nowait

insert @ltbl_diff select 1,datediff (day,max (applied_date),getdate ()) from AP_Apply

update AP_Apply set applied_date = case when applied_date is not null then dateadd (day,(select diff from @ltbl_diff where valindex = 1),applied_date) else applied_date end


AP_Cheque

delete @ltbl_diff

raiserror ('AP_Cheque 3 of 39',0,1) with nowait

insert @ltbl_diff select 1,datediff (day,max (cheque_date),getdate ()) from AP_Cheque

update AP_Cheque set cheque_date = case when cheque_date is not null then dateadd (day,(select diff from @ltbl_diff where valindex = 1),cheque_date) else cheque_date end ,updated_by = 'date_update' ,updated_on = getdate ()


AP_Cheque_Detail

delete @ltbl_diff

raiserror ('AP_Cheque_Detail 4 of 39',0,1) with nowait

insert @ltbl_diff select 1,datediff (day,max (document_date),getdate ()) from AP_Cheque_Detail

update AP_Cheque_Detail set document_date = case when document_date is not null then dateadd (day,(select diff from @ltbl_diff where valindex = 1),document_date) else document_date end


AP_Item

delete @ltbl_diff

raiserror ('AP_Item 5 of 39',0,1) with nowait

insert @ltbl_diff select 1,datediff (day,max (discount_due_date),getdate ()) from AP_Item insert @ltbl_diff select 2,datediff (day,max (document_date),getdate ()) from AP_Item insert @ltbl_diff select 3,datediff (day,max (due_date),getdate ()) from AP_Item

update AP_Item set discount_due_date = case when discount_due_date is not null then dateadd (day,(select diff from @ltbl_diff where valindex = 1),discount_due_date) else discount_due_date end ,document_date = case when document_date is not null then dateadd (day,(select diff from @ltbl_diff where valindex = 2),document_date) else document_date end ,due_date = case when due_date is not null then dateadd (day,(select diff from @ltbl_diff where valindex = 3),due_date) else due_date end ,updated_by = 'date_update' ,updated_on = getdate ()


AR_Apply

delete @ltbl_diff

raiserror ('Accounting_Period 6 of 39',0,1) with nowait

insert @ltbl_diff select 1,datediff (day,max (applied_date),getdate ()) from AR_Apply

update AR_Apply set applied_date = case when applied_date is not null then dateadd (day,(select diff from @ltbl_diff where valindex = 1),applied_date) else applied_date end


AR_Item

delete @ltbl_diff

raiserror ('AR_Item 7 of 39',0,1) with nowait

insert @ltbl_diff select 1,datediff (day,max (discount_due_date),getdate ()) from AR_Item insert @ltbl_diff select 2,datediff (day,max (document_date),getdate ()) from AR_Item insert @ltbl_diff select 3,datediff (day,max (due_date),getdate ()) from AR_Item insert @ltbl_diff select 4,datediff (day,max (holdback_due_date),getdate ()) from AR_Item

update AR_Item set discount_due_date = case when discount_due_date is not null then dateadd (day,(select diff from @ltbl_diff where valindex = 1),discount_due_date) else discount_due_date end ,document_date = case when document_date is not null then dateadd (day,(select diff from @ltbl_diff where valindex = 2),document_date) else document_date end ,due_date = case when due_date is not null then dateadd (day,(select diff from @ltbl_diff where valindex = 3),due_date) else due_date end ,holdback_due_date = case when holdback_due_date is not null then dateadd (day,(select diff from @ltbl_diff where valindex = 4),holdback_due_date) else holdback_due_date end ,updated_by = 'date_update' ,updated_on = getdate ()


Firm_Account

delete @ltbl_diff

raiserror ('Firm_Account 8 of 39',0,1) with nowait

insert @ltbl_diff select 1,datediff (day,max (credit_review_date),getdate ()) from Firm_Account;

disable trigger FirmAccountUpdateTrigger on Firm_Account;

update Firm_Account set credit_review_date = case when credit_review_date is not null then dateadd (day,(select diff from @ltbl_diff where valindex = 1),credit_review_date) else credit_review_date end ,updated_by = 'date_update' ,updated_on = getdate ();

enable trigger FirmAccountUpdateTrigger on Firm_Account;


Foreign_Exchange

delete @ltbl_diff

raiserror ('Foreign_Exchange 9 of 39',0,1) with nowait

insert @ltbl_diff select 1,datediff (day,max (effective_date),getdate ()) from Foreign_Exchange

update Foreign_Exchange set effective_date = case when effective_date is not null then dateadd (day,(select diff from @ltbl_diff where valindex = 1),effective_date) else effective_date end ,updated_by = 'date_update' ,updated_on = getdate ()


GL_Item

delete @ltbl_diff

raiserror ('GL_Item 10 of 39',0,1) with nowait

insert @ltbl_diff select 1,datediff (day,max (transaction_date),getdate ()) from GL_Item

update GL_Item set transaction_date = case when transaction_date is not null then dateadd (day,(select diff from @ltbl_diff where valindex = 1),transaction_date) else transaction_date end ,updated_by = 'date_update' ,updated_on = getdate ()


GL_Journal

delete @ltbl_diff

raiserror ('GL_Journal 11 of 39',0,1) with nowait

insert @ltbl_diff select 1,datediff (day,max (journal_date),getdate ()) from GL_Journal

update GL_Journal set journal_date = case when journal_date is not null then dateadd (day,(select diff from @ltbl_diff where valindex = 1),journal_date) else journal_date end ,updated_by = 'date_update' ,updated_on = getdate ()


GL_Reconciliation

delete @ltbl_diff

raiserror ('GL_Reconciliation 12 of 39',0,1) with nowait

insert @ltbl_diff select 1,datediff (day,max (reconciliation_date),getdate ()) from GL_Reconciliation

update GL_Reconciliation set reconciliation_date = case when reconciliation_date is not null then dateadd (day,(select diff from @ltbl_diff where valindex = 1),reconciliation_date) else reconciliation_date end ,updated_by = 'date_update' ,updated_on = getdate ()


GL_Reconciliation_Detail

delete @ltbl_diff

raiserror ('GL_Reconciliation_Detail 13 of 39',0,1) with nowait

insert @ltbl_diff select 1,datediff (day,max (document_date),getdate ()) from GL_Reconciliation_Detail

update GL_Reconciliation_Detail set document_date = case when document_date is not null then dateadd (day,(select diff from @ltbl_diff where valindex = 1),document_date) else document_date end ,updated_by = 'date_update' ,updated_on = getdate ()


IC_Coil

delete @ltbl_diff

raiserror ('IC_Coil 14 of 39',0,1) with nowait

insert @ltbl_diff select 1,datediff (day,max (received_date),getdate ()) from IC_Coil

update IC_Coil set received_date = case when received_date is null then received_date else dateadd (day,(select diff from @ltbl_diff where valindex = 1),received_date) end ,updated_by = 'date_update' ,updated_on = getdate ()


IC_Production_Batch

delete @ltbl_diff

raiserror ('IC_Production_Batch 15 of 39',0,1) with nowait

insert @ltbl_diff select 1,datediff (day,max (batch_date),getdate ()) from IC_Production_Batch

update IC_Production_Batch set batch_date = case when batch_date is not null then dateadd (day,(select diff from @ltbl_diff where valindex = 1),batch_date) else batch_date end ,updated_by = 'date_update' ,updated_on = getdate ()


IC_Production_Order

delete @ltbl_diff

raiserror ('IC_Production_Order 16 of 39',0,1) with nowait

insert @ltbl_diff select 1,datediff (day,max (date_required),getdate ()) from IC_Production_Order insert @ltbl_diff select 2,datediff (day,max (production_order_date),getdate ()) from IC_Production_Order

update IC_Production_Order set date_required = case when date_required is not null then dateadd (day,(select diff from @ltbl_diff where valindex = 1),date_required) else date_required end ,production_order_date = case when production_order_date is not null then dateadd (day,(select diff from @ltbl_diff where valindex = 2),production_order_date) else production_order_date end ,updated_by = 'date_update' ,updated_on = getdate ()


IC_Ticket

delete @ltbl_diff

raiserror ('IC_Ticket 17 of 39',0,1) with nowait

insert @ltbl_diff select 1,datediff (day,max (ticket_date),getdate ()) from IC_Ticket

update IC_Ticket set ticket_date = case when ticket_date is not null then dateadd (day,(select diff from @ltbl_diff where valindex = 1),ticket_date) else ticket_date end ,updated_by = 'date_update' ,updated_on = getdate ()


Portal_Notification

delete @ltbl_diff

raiserror ('Portal_Notification 18 of 39',0,1) with nowait

insert @ltbl_diff select 1,datediff (day,max (notification_date),getdate ()) from Portal_Notification

update Portal_Notification set notification_date = case when notification_date is not null then dateadd (day,(select diff from @ltbl_diff where valindex = 1),notification_date) else notification_date end ,updated_by = 'date_update' ,updated_on = getdate ()


Portal_Notification_Read

delete @ltbl_diff

raiserror ('Portal_Notification_Read 19 of 39',0,1) with nowait

insert @ltbl_diff select 1,datediff (day,max (read_date),getdate ()) from Portal_Notification_Read

update Portal_Notification_Read set read_date = case when read_date is not null then dateadd (day,(select diff from @ltbl_diff where valindex = 1),read_date) else read_date end


Print_Job

delete @ltbl_diff

raiserror ('Print_Job 20 of 39',0,1) with nowait

insert @ltbl_diff select 1,datediff (day,max (print_date),getdate ()) from Print_Job insert @ltbl_diff select 2,datediff (day,max (printed_date),getdate ()) from Print_Job

update Print_Job set print_date = case when print_date is not null then dateadd (day,(select diff from @ltbl_diff where valindex = 1),print_date) else print_date end ,printed_date = case when printed_date is not null then dateadd (day,(select diff from @ltbl_diff where valindex = 2),printed_date) else printed_date end ,updated_by = 'date_update' ,updated_on = getdate ()


Product_Ledger

delete @ltbl_diff

raiserror ('Product_Ledger 21 of 39',0,1) with nowait

insert @ltbl_diff select 1,datediff (day,max (transaction_date),getdate ()) from Product_Ledger;

disable trigger ProductLedgerUpdateTrigger on Product_Ledger;

update Product_Ledger set transaction_date = case when transaction_date is not null then dateadd (day,(select diff from @ltbl_diff where valindex = 1),transaction_date) else transaction_date end ,updated_by = 'date_update' ,updated_on = getdate ();

enable trigger ProductLedgerUpdateTrigger on Product_Ledger;


Product_Log

delete @ltbl_diff

raiserror ('Product_Log 22 of 39',0,1) with nowait

insert @ltbl_diff select 1,datediff (day,max (event_date),getdate ()) from Product_Log;

disable trigger ProductLogUpdateTrigger on Product_Log;

update Product_Log set event_date = case when event_date is not null then dateadd (day,(select diff from @ltbl_diff where valindex = 1),event_date) else event_date end ,updated_by = 'date_update' ,updated_on = getdate ();

enable trigger ProductLogUpdateTrigger on Product_Log;


Product_Lot

delete @ltbl_diff

raiserror ('Product_Lot 23 of 39',0,1) with nowait

insert @ltbl_diff select 1,datediff (day,max (document_date),getdate ()) from Product_Lot;

update Product_Lot set document_date = case when document_date is not null then dateadd (day,(select diff from @ltbl_diff where valindex = 1),document_date) else document_date end


Product_Warehouse

delete @ltbl_diff

raiserror ('Product_Warehouse 24 of 39',0,1) with nowait

insert @ltbl_diff select 1,datediff (day,max (last_count_date),getdate ()) from Product_Warehouse; insert @ltbl_diff select 2,datediff (day,max (last_receipt_date),getdate ()) from Product_Warehouse; insert @ltbl_diff select 3,datediff (day,max (last_sales_date),getdate ()) from Product_Warehouse;

disable trigger ProductWarehouseUpdateTrigger on Product_Warehouse;

update Product_Warehouse set last_count_date = case when last_count_date is not null then dateadd (day,(select diff from @ltbl_diff where valindex = 1),last_count_date) else last_count_date end ,last_receipt_date = case when last_receipt_date is not null then dateadd (day,(select diff from @ltbl_diff where valindex = 2),last_receipt_date) else last_receipt_date end ,last_sales_date = case when last_sales_date is not null then dateadd (day,(select diff from @ltbl_diff where valindex = 3),last_sales_date) else last_sales_date end ,updated_by = 'date_update' ,updated_on = getdate ();

enable trigger ProductWarehouseUpdateTrigger on Product_Warehouse;


Purchase_Order

delete @ltbl_diff

raiserror ('Purchase_Order 25 of 39',0,1) with nowait

insert @ltbl_diff select 1,datediff (day,max (eta_date),getdate ()) from Purchase_Order; insert @ltbl_diff select 2,datediff (day,max (purchase_order_date),getdate ()) from Purchase_Order;

update Purchase_Order set eta_date = case when eta_date is not null then dateadd (day,(select diff from @ltbl_diff where valindex = 1),eta_date) else eta_date end ,purchase_order_date = case when purchase_order_date is not null then dateadd (day,(select diff from @ltbl_diff where valindex = 2),purchase_order_date) else purchase_order_date end ,updated_by = 'date_update' ,updated_on = getdate ();


Purchase_Order_Receipt

delete @ltbl_diff

raiserror ('Purchase_Order_Receipt 26 of 39',0,1) with nowait

insert @ltbl_diff select 1,datediff (day,max (invoice_date),getdate ()) from Purchase_Order_Receipt; insert @ltbl_diff select 2,datediff (day,max (packing_slip_date),getdate ()) from Purchase_Order_Receipt; insert @ltbl_diff select 3,datediff (day,max (purchase_order_receipt_date),getdate ()) from Purchase_Order_Receipt;

update Purchase_Order_Receipt set invoice_date = case when invoice_date is not null then dateadd (day,(select diff from @ltbl_diff where valindex = 1),invoice_date) else invoice_date end ,packing_slip_date = case when packing_slip_date is not null then dateadd (day,(select diff from @ltbl_diff where valindex = 2),packing_slip_date) else packing_slip_date end ,purchase_order_receipt_date = case when purchase_order_receipt_date is not null then dateadd (day,(select diff from @ltbl_diff where valindex = 3),purchase_order_receipt_date) else purchase_order_receipt_date end ,updated_by = 'date_update' ,updated_on = getdate ();


Rate_Discount_Period

delete @ltbl_diff

raiserror ('Rate_Discount_Period 27 of 39',0,1) with nowait

insert @ltbl_diff select 1,datediff (day,max (effective_date),getdate ()) from Rate_Discount_Period; insert @ltbl_diff select 2,datediff (day,max (expiry_date),getdate ()) from Rate_Discount_Period; insert @ltbl_diff select 3,datediff (day,max (review_date),getdate ()) from Rate_Discount_Period;

update Rate_Discount_Period set effective_date = case when effective_date is not null then dateadd (day,(select diff from @ltbl_diff where valindex = 1),effective_date) else effective_date end ,expiry_date = case when expiry_date is not null then dateadd (day,(select diff from @ltbl_diff where valindex = 2),expiry_date) else expiry_date end ,review_date = case when review_date is not null then dateadd (day,(select diff from @ltbl_diff where valindex = 3),review_date) else review_date end ,updated_by = 'date_update' ,updated_on = getdate ();


Rate_Period

delete @ltbl_diff

raiserror ('Rate_Period 26 of 39',0,1) with nowait

insert @ltbl_diff select 1,datediff (day,max (effective_date),getdate ()) from Rate_Period; insert @ltbl_diff select 2,datediff (day,max (expiry_date),getdate ()) from Rate_Period; insert @ltbl_diff select 3,datediff (day,max (review_date),getdate ()) from Rate_Period;

update Rate_Period set effective_date = case when effective_date is not null then dateadd (day,(select diff from @ltbl_diff where valindex = 1),effective_date) else effective_date end ,expiry_date = case when expiry_date is not null then dateadd (day,(select diff from @ltbl_diff where valindex = 2),expiry_date) else expiry_date end ,review_date = case when review_date is not null then dateadd (day,(select diff from @ltbl_diff where valindex = 3),review_date) else review_date end ,updated_by = 'date_update' ,updated_on = getdate ();


Sales_Order

delete @ltbl_diff

raiserror ('Sales_Order 29 of 39',0,1) with nowait

insert @ltbl_diff select 1,datediff (day,max (acknowledged_date),getdate ()) from Sales_Order; insert @ltbl_diff select 2,datediff (day,max (completed_date),getdate ()) from Sales_Order; insert @ltbl_diff select 3,datediff (day,max (customer_po_date),getdate ()) from Sales_Order; insert @ltbl_diff select 4,datediff (day,max (delivered_date),getdate ()) from Sales_Order; insert @ltbl_diff select 5,datediff (day,max (earliest_date),getdate ()) from Sales_Order; insert @ltbl_diff select 6,datediff (day,max (estimated_delivery_date),getdate ()) from Sales_Order; insert @ltbl_diff select 7,datediff (day,max (invoice_date),getdate ()) from Sales_Order; insert @ltbl_diff select 8,datediff (day,max (latest_date),getdate ()) from Sales_Order; insert @ltbl_diff select 9,datediff (day,max (order_date),getdate ()) from Sales_Order; insert @ltbl_diff select 10,datediff (day,max (scheduled_date),getdate ()) from Sales_Order; insert @ltbl_diff select 11,datediff (day,max (ship_date),getdate ()) from Sales_Order; insert @ltbl_diff select 12,datediff (day,max (transmitted_date),getdate ()) from Sales_Order;

disable trigger SalesOrderUpdateTrigger on Sales_Order;

update Sales_Order set acknowledged_date = case when acknowledged_date is not null then dateadd (day,(select diff from @ltbl_diff where valindex = 1),acknowledged_date) else acknowledged_date end ,completed_date = case when completed_date is not null then dateadd (day,(select diff from @ltbl_diff where valindex = 2),completed_date) else completed_date end ,customer_po_date = case when customer_po_date is not null then dateadd (day,(select diff from @ltbl_diff where valindex = 3),customer_po_date) else customer_po_date end ,delivered_date = case when delivered_date is not null then dateadd (day,(select diff from @ltbl_diff where valindex = 4),delivered_date) else delivered_date end ,earliest_date = case when earliest_date is not null then dateadd (day,(select diff from @ltbl_diff where valindex = 5),earliest_date) else earliest_date end ,estimated_delivery_date = case when estimated_delivery_date is not null then dateadd (day,(select diff from @ltbl_diff where valindex = 6),estimated_delivery_date) else estimated_delivery_date end ,invoice_date = case when invoice_date is not null then dateadd (day,(select diff from @ltbl_diff where valindex = 7),invoice_date) else invoice_date end ,latest_date = case when latest_date is not null then dateadd (day,(select diff from @ltbl_diff where valindex = 8),latest_date) else latest_date end ,order_date = case when order_date is not null then dateadd (day,(select diff from @ltbl_diff where valindex = 9),order_date) else order_date end ,scheduled_date = case when scheduled_date is not null then dateadd (day,(select diff from @ltbl_diff where valindex = 10),scheduled_date) else scheduled_date end ,ship_date = case when ship_date is not null then dateadd (day,(select diff from @ltbl_diff where valindex = 11),ship_date) else ship_date end ,transmitted_date = case when transmitted_date is not null then dateadd (day,(select diff from @ltbl_diff where valindex = 12),transmitted_date) else transmitted_date end ,updated_by = 'date_update' ,updated_on = getdate ();

enable trigger SalesOrderUpdateTrigger on Sales_Order;


Sales_Tax

delete @ltbl_diff

raiserror ('Sales_Tax 30 of 39',0,1) with nowait

insert @ltbl_diff select 1,datediff (day,max (effective_date),getdate ()) from Sales_Tax;

update Sales_Tax set effective_date = case when effective_date is not null then dateadd (day,(select diff from @ltbl_diff where valindex = 1),effective_date) else effective_date end ,updated_by = 'date_update' ,updated_on = getdate ();


TA_Sales_Order_Line

delete @ltbl_diff

raiserror ('TA_Sales_Order_Line 31 of 39',0,1) with nowait

insert @ltbl_diff select 1,datediff (day,max (departure_date),getdate ()) from TA_Sales_Order_Line; insert @ltbl_diff select 2,datediff (day,max (policy_date),getdate ()) from TA_Sales_Order_Line; insert @ltbl_diff select 3,datediff (day,max (return_date),getdate ()) from TA_Sales_Order_Line;

update TA_Sales_Order_Line set departure_date = case when departure_date is not null then dateadd (day,(select diff from @ltbl_diff where valindex = 1),departure_date) else departure_date end ,policy_date = case when policy_date is not null then dateadd (day,(select diff from @ltbl_diff where valindex = 2),policy_date) else policy_date end ,return_date = case when return_date is not null then dateadd (day,(select diff from @ltbl_diff where valindex = 3),return_date) else return_date end ,updated_by = 'date_update' ,updated_on = getdate ();


TE_Lot

delete @ltbl_diff

raiserror ('TE_Lot 32 of 39',0,1) with nowait

insert @ltbl_diff select 1,datediff (day,max (permit_request_date),getdate ()) from TE_Lot;

update TE_Lot set permit_request_date = case when permit_request_date is not null then dateadd (day,(select diff from @ltbl_diff where valindex = 1),permit_request_date) else permit_request_date end ,updated_by = 'date_update' ,updated_on = getdate ();


TE_Lot_Billing

delete @ltbl_diff

raiserror ('TE_Lot_Billing 33 of 39',0,1) with nowait

insert @ltbl_diff select 1,datediff (day,max (invoice_date),getdate ()) from TE_Lot_Billing;

update TE_Lot_Billing set invoice_date = case when invoice_date is not null then dateadd (day,(select diff from @ltbl_diff where valindex = 1),invoice_date) else invoice_date end ,updated_by = 'date_update' ,updated_on = getdate ();


TE_Lot_Inspection

delete @ltbl_diff

raiserror ('TE_Lot_Inspection 34 of 39',0,1) with nowait

insert @ltbl_diff select 1,datediff (day,max (inspection_date),getdate ()) from TE_Lot_Inspection; insert @ltbl_diff select 2,datediff (day,max (inspection_request_date),getdate ()) from TE_Lot_Inspection;

update TE_Lot_Inspection set inspection_date = case when inspection_date is not null then dateadd (day,(select diff from @ltbl_diff where valindex = 1),inspection_date) else inspection_date end ,inspection_request_date = case when inspection_request_date is not null then dateadd (day,(select diff from @ltbl_diff where valindex = 2),inspection_request_date) else inspection_request_date end ,updated_by = 'date_update' ,updated_on = getdate ();


TE_Lot_Inspection_Result

delete @ltbl_diff

raiserror ('TE_Lot_Inspection_Result 35 of 39',0,1) with nowait

insert @ltbl_diff select 1,datediff (day,max (inspection_date),getdate ()) from TE_Lot_Inspection_Result;

update TE_Lot_Inspection_Result set inspection_date = case when inspection_date is not null then dateadd (day,(select diff from @ltbl_diff where valindex = 1),inspection_date) else inspection_date end ,updated_by = 'date_update' ,updated_on = getdate ();


TE_Lot_Option

delete @ltbl_diff

raiserror ('TE_Lot_Option 36 of 39',0,1) with nowait

insert @ltbl_diff select 1,datediff (day,max (invoice_date),getdate ()) from TE_Lot_Option;

update TE_Lot_Option set invoice_date = case when invoice_date is not null then dateadd (day,(select diff from @ltbl_diff where valindex = 1),invoice_date) else invoice_date end ,updated_by = 'date_update' ,updated_on = getdate ();


TE_Lot_PO

delete @ltbl_diff

raiserror ('TE_Lot_PO 37 of 39',0,1) with nowait

insert @ltbl_diff select 1,datediff (day,max (po_date),getdate ()) from TE_Lot_PO;

update TE_Lot_PO set po_date = case when po_date is not null then dateadd (day,(select diff from @ltbl_diff where valindex = 1),po_date) else po_date end ,updated_by = 'date_update' ,updated_on = getdate ();


TE_Model_Billing

delete @ltbl_diff

raiserror ('TE_Model_Billing 28 of 39',0,1) with nowait

insert @ltbl_diff select 1,datediff (day,max (effective_date),getdate ()) from TE_Model_Billing;

update TE_Model_Billing set effective_date = case when effective_date is not null then dateadd (day,(select diff from @ltbl_diff where valindex = 1),effective_date) else effective_date end ,updated_by = 'date_update' ,updated_on = getdate ();


WD_Quote

delete @ltbl_diff

raiserror ('WD_Quote 39 of 39',0,1) with nowait

insert @ltbl_diff select 1,datediff (day,max (quote_date),getdate ()) from WD_Quote;

update WD_Quote set quote_date = case when quote_date is not null then dateadd (day,(select diff from @ltbl_diff where valindex = 1),quote_date) else quote_date end ,updated_by = 'date_update' ,updated_on = getdate ();

rollback transaction --commit transaction end



Return to Show Database