Back to Browse

How to delete duplicate rows in sql | How to delete duplicate records from a table in SQL

172 views
Mar 26, 2022
4:29

How to delete duplicate rows in sql | How to delete duplicate records from a table in SQL Table : CREATE TABLE [dbo].[Emp]( [ID] [int] NULL, [FirstName] [nvarchar](50) NULL, [LastName] [nvarchar](50) NULL, [Gender] [nvarchar](50) NULL, [Salary] [int] NULL ) Query to delete the duplicate records : WITH EmpCTE AS ( SELECT *, ROW_NUMBER()OVER(PARTITION BY ID ORDER BY ID) AS RowNumber FROM EMP ) DELETE FROM EmpCTE WHERE RowNumber ] 1 #SQLInterviewQuestionsandanswers #sqlInterviewQuestions #sqlInterviewQuestionsForTesting #sqlInterviewQuestionsQuery #sqlInterviewQuestionsOnJoins #sqlTechnicalInterviewQuestions #SQLforETLTesters #CommonSqlInterviewQuestions #ETLTesting #DeleteDuplicateRecordsFromTable

Download

0 formats

No download links available.

How to delete duplicate rows in sql | How to delete duplicate records from a table in SQL | NatokHD