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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Rahul BoratePosted Mar 22, 2016, 6:25 AM
Kunal PatelPosted Mar 22, 2016, 5:55 AM
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
Shakti Singh DulawatPosted Mar 22, 2016, 4:21 AM
Dorababu MekaPosted Mar 22, 2016, 4:19 AM