Remove duplicate Data using GroupBy

Remove duplicate data

 

DECLARE @tbl TABLE(
id INT IDENTITY(1, 1)
, col1 VARCHAR(20)
)
INSERT INTO @tbl VALUES ('Unique data')
INSERT INTO @tbl VALUES ('duplicate data')
INSERT INTO @tbl VALUES ('duplicate data')
select * From @tbl
DELETE
FROM @tbl
WHERE ID NOT IN
(
SELECT MAX(ID)
FROM @tbl
GROUP BY col1)
select * From @tbl
Remove duplicate Data using GroupBy was last modified: October 1st, 2017 by Justin Antony

Change Data capture in Datawarehouse using SQL command

USE DBNAME
EXEC sys.sp_cdc_enable_db

This will enable the change capture in the database.

Enable in table level:

EXECUTE Sys.sp_cdc_enable_table @Source_Schema = N’dbo’, @source_name = N’tblname’,@role_name= N’adminCDC’,@Support_net_changes = 1,@captured_Column_list = N’col1,col2,col3′

Change Data capture in Datawarehouse using SQL command was last modified: October 1st, 2017 by Justin Antony