How to check duplicate save record in sql server
how to check duplicate save record in sql server (eg 'John Smith' and 'John Smith') with .net
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Kunal PatelRank #1,359 · 1.2K reputationPosted Mar 22, 2016, 1:55 AM EDT
AS
(
SELECT Name,ROW_NUMBER() OVER (PARTITION BY Name ORDER BY Name
) AS duplicatecount FROM YourTable
)
-- for show which field is duplicate from table
SELECT * FROM CTE WHERE duplicatecount > 1
-- remove duplicate field from table
--DELETE FROM CTE WHERE duplicatecount > 1
Dorababu MekaRank #457 · 5.5K reputationPosted Mar 22, 2016, 12:19 AM EDT
Shakti Singh DulawatRank #668 · 3.6K reputationPosted Mar 22, 2016, 12:21 AM EDT
Rahul Borate89 reputationPosted Mar 22, 2016, 2:25 AM EDT