Header Ads Widget

Responsive Advertisement

Ticker

6/recent/ticker-posts

How to remove duplicate values from SQL table

 Below SQL queries will helpful to remove duplicate values from sql table:

1. 

DELETE FROM table WHERE ID IN (
SELECT 
ID, COUNT(ID) 
FROM   table
GROUP BY  ID
HAVING 
COUNT (ID) > 1);

 

2.

Delete from [master].[dbo].[EMP] where EMP_ID not in (
SELECT MAX(EMP_ID) AS MaxRecordID
FROM [master].[dbo].[EMP]
GROUP BY emp_name, 
EMP_SALARY )

Post a Comment

0 Comments