sql server删除重复的数据保留一条
DELETE FROM [TCX_1710_SHZJ].[dbo].[PR_BindingTray]
WHERE 1=1
AND SNum in (SELECT * FROM ( (SELECT SNum FROM [TCX_1710_SHZJ].[dbo].[PR_BindingTray] GROUP BY SNum HAVING COUNT( SNum )>1) ) a)
AND id not in (SELECT * FROM ( (SELECT MIN(id) ids FROM [TCX_1710_SHZJ].[dbo].[PR_BindingTray] GROUP BY SNum HAVING COUNT(SNum)>1) ) b)