Загрузка...

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

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

Видео How to delete duplicate rows in sql | How to delete duplicate records from a table in SQL канала ALLCPL
Страницу в закладки Мои закладки
Все заметки Новая заметка Страницу в заметки