Posts

Showing posts from July, 2017

Merge Example

--Create a target table CREATE TABLE Products ( ProductID INT PRIMARY KEY, ProductName VARCHAR(100), Rate MONEY ) GO --Insert records into target table INSERT INTO Products VALUES (1, 'Tea', 10.00), (2, 'Coffee', 20.00), (3, 'Muffin', 30.00), (4, 'Biscuit', 40.00) GO --Create source table CREATE TABLE UpdatedProducts ( ProductID INT PRIMARY KEY, ProductName VARCHAR(100), Rate MONEY ) GO --Insert records into source table INSERT INTO UpdatedProducts VALUES (1, 'Tea', 10.00), (2, 'Coffee', 25.00), (3, 'Muffin', 35.00), (5, 'Pizza', 60.00) GO SELECT * FROM Products SELECT * FROM UpdatedProducts GO ----------------------------------------------------- --Synchronize the target table with --refreshed data from source table MERGE Products AS TARGET USING UpdatedProducts AS SOURCE ON ( TARGET.ProductID = SOURCE.ProductID ) --When records are matched, update --the records if there is any...

Change Data Capture (CDC) in SQL

Change Data Capture (CDC) in SQL some cdc helpful links: https://www.red-gate.com/simple-talk/sql/learn-sql-server/introduction-to-change-data-capture-cdc-in-sql-server-2008/ https://sqlblog.org/2007/06/21/playing-with-cdc-in-katmai