删除重复记录的办法

1. 增加字段 flag
2. 标记不需要删除的记录
UPDATE Users
SET flag = 1
FROM (SELECT MAX(UserId) AS userid
                       FROM          Users AS Users_1
                       GROUP BY UserName) AS a INNER JOIN
                      Users ON Users.UserId = a.userid
3.删除记录
DELETE FROM users WHERE flag IS NULL
posted @ 2006-11-13 15:57  海潮的博客  阅读(391)  评论(0编辑  收藏  举报