sql server 删除重复数据 保留id大的

来源:互联网 发布:投资理财网络平台排名 编辑:程序博客网 时间:2024/05/18 14:26
DELETE  FROM [Translation]  where keyid in  
(SELECT T.KeyID FROM [Translation] as T WHERE T.PageID=6088 And T.KeyID<=61866 And
T.TranslationKey IN (SELECT T1.TranslationKey FROM [Translation] as T1 GROUP BY TranslationKey HAVING COUNT(T1.TranslationKey)>1) 

AND T.KeyID NOT IN (SELECT MAX(T2.KeyID) FROM [Translation] as T2 GROUP BY T2.TranslationKey HAVING COUNT(T2.TranslationKey)>1)) 




DELETE  FROM [Translation]  where keyid in  (SELECT T.KeyID FROM [Translation] as T WHERE T.PageID=6088 And T.KeyID<=61866 AndT.TranslationKey IN (SELECT T1.TranslationKey FROM [Translation] as T1 GROUP BY TranslationKey HAVING COUNT(T1.TranslationKey)>1) AND T.KeyID NOT IN (SELECT MAX(T2.KeyID) FROM [Translation] as T2 GROUP BY T2.TranslationKey HAVING COUNT(T2.TranslationKey)>1)) 


0 0
原创粉丝点击