Integration.GetTransactionUpdates
Documentation | WideWorldImporters |
Schema | Integration |
Name | GetTransactionUpdates |
Helper procedures for the ETL package
Input/Output
Mode | Name | Data type | Description | |
---|---|---|---|---|
1 | IN | LastCutoff | datetime2(7) | |
2 | IN | NewCutoff | datetime2(7) |
Script
CREATE PROCEDURE Integration.GetTransactionUpdates @LastCutoff datetime2(7), @NewCutoff datetime2(7) WITH EXECUTE AS OWNER AS BEGIN SET NOCOUNT ON; SET XACT_ABORT ON; SELECT CAST(ct.TransactionDate AS date) AS [Date Key], ct.CustomerTransactionID AS [WWI Customer Transaction ID], CAST(NULL AS int) AS [WWI Supplier Transaction ID], ct.InvoiceID AS [WWI Invoice ID], CAST(NULL AS int) AS [WWI Purchase Order ID], CAST(NULL AS nvarchar(20)) AS [Supplier Invoice Number], ct.AmountExcludingTax AS [Total Excluding Tax], ct.TaxAmount AS [Tax Amount], ct.TransactionAmount AS [Total Including Tax], ct.OutstandingBalance AS [Outstanding Balance], ct.IsFinalized AS [Is Finalized], COALESCE(i.CustomerID, ct.CustomerID) AS [WWI Customer ID], ct.CustomerID AS [WWI Bill To Customer ID], CAST(NULL AS int) AS [WWI Supplier ID], ct.TransactionTypeID AS [WWI Transaction Type ID], ct.PaymentMethodID AS [WWI Payment Method ID], ct.LastEditedWhen AS [Last Modified When] FROM Sales.CustomerTransactions AS ct LEFT OUTER JOIN Sales.Invoices AS i ON ct.InvoiceID = i.InvoiceID WHERE ct.LastEditedWhen > @LastCutoff AND ct.LastEditedWhen <= @NewCutoff UNION ALL SELECT CAST(st.TransactionDate AS date) AS [Date Key], CAST(NULL AS int) AS [WWI Customer Transaction ID], st.SupplierTransactionID AS [WWI Supplier Transaction ID], CAST(NULL AS int) AS [WWI Invoice ID], st.PurchaseOrderID AS [WWI Purchase Order ID], st.SupplierInvoiceNumber AS [Supplier Invoice Number], st.AmountExcludingTax AS [Total Excluding Tax], st.TaxAmount AS [Tax Amount], st.TransactionAmount AS [Total Including Tax], st.OutstandingBalance AS [Outstanding Balance], st.IsFinalized AS [Is Finalized], CAST(NULL AS int) AS [WWI Customer ID], CAST(NULL AS int) AS [WWI Bill To Customer ID], st.SupplierID AS [WWI Supplier ID], st.TransactionTypeID AS [WWI Transaction Type ID], st.PaymentMethodID AS [WWI Payment Method ID], st.LastEditedWhen AS [Last Modified When] FROM Purchasing.SupplierTransactions AS st WHERE st.LastEditedWhen > @LastCutoff AND st.LastEditedWhen <= @NewCutoff; RETURN 0; END; |
Exported: 2019-02-04 23:04, Last imported: 2018-08-10 09:51