从相当大的SQL Server表中删除重复行的最佳方法是什么(即300,000多行)?
当然,由于RowID身份字段的存在,行不会是完美的重复.
MyTable的
RowID int not null identity(1,1) primary key,
Col1 varchar(20) not null,
Col2 varchar(2048) not null,
Col3 tinyint not null
Run Code Online (Sandbox Code Playgroud) 假设我的表中有重复的行,而且我的数据库设计是第3类: -
Insert Into tblProduct (ProductId,ProductName,Description,Category) Values (1,'Cinthol','cosmetic soap','soap');
Insert Into tblProduct (ProductId,ProductName,Description,Category) Values (1,'Cinthol','cosmetic soap','soap');
Insert Into tblProduct (ProductId,ProductName,Description,Category) Values (1,'Cinthol','cosmetic soap','soap');
Insert Into tblProduct (ProductId,ProductName,Description,Category) Values (1,'Lux','cosmetic soap','soap');
Insert Into tblProduct (ProductId,ProductName,Description,Category) Values (1,'Crowning Glory','cosmetic soap','soap');
Insert Into tblProduct (ProductId,ProductName,Description,Category) Values (2,'Cinthol','nice soap','soap');
Insert Into tblProduct (ProductId,ProductName,Description,Category) Values (3,'Lux','nice soap','soap');
Insert Into tblProduct (ProductId,ProductName,Description,Category) Values (3,'Lux','nice soap','soap');
Run Code Online (Sandbox Code Playgroud)
我希望每个表中只有1个实例存在于我的表中.因此,2nd, 3rd and last row应该删除完全相同的whcih.我可以为此写什么查询?可以在不创建临时表的情况下完成吗?只需一个查询?
提前致谢 :)