Skip to main content

Posts

Showing posts from August, 2020

How to delete duplicate records from a table by using a CTA in SQL Server

You can use a CTA (Common Table Expression)  to delete duplicate records from a SQL Server table by writing a statement like this; WITH Location_CTE AS ( SELECT [Id]       , [LocationQuery]       , [DetailsResponseJson]       , [DateCreated]       , [DateUpdated] ,          ROW_NUMBER () OVER (               PARTITION BY                      [LocationQuery]               ORDER BY                      [LocationQuery]          ) Row_Num   FROM [dbo] . [Lo...