有没有办法在表中找到不需要指定所有/某些字段的重复项? 我需要在几个表上执行此操作,并希望有一个可以在循环中使用的公共代码(尽可能简单),(只需更改tablename)。
所以基本上我一直在寻找相当于的东西:
SELECT *
, COUNT(*) TotalCount
FROM tableName
GROUP BY *
HAVING COUNT(*) > 1
ORDER BY COUNT(*) DESC
有没有办法这样做?
答案 0 :(得分:0)
尝试此操作,但在尝试
之前请先备份delete T from
(
select row_number() over(order by item) as row_number, * from @t
) T
where row_number not in
(
select min(row_number) from (select row_number() over(order by item) as row_number, * from tableName) T
group by item
)
我从here
的例子中得到了这个