TRY: Create Table test(tid int identity(1,1),tstr varchar(5)) Insert into test Select 'texta' Union All Select 'textb' Union All Select 'texta' Union All Select 'textb'Select * From testDelete a From test a left outer join test b on a.tstr=b.tstr Where a.tid>b.tidSelect * From testDrop Table test/* tid tstr ----------- ----- 1 texta 2 textb 3 texta 4 textb(所影响的行数为 4 行) tid tstr ----------- ----- 1 texta 2 textb(所影响的行数为 2 行) */
Create Table test(tid int identity(1,1),tstr varchar(5))
Insert into test Select 'texta' Union All
Select 'textb' Union All
Select 'texta' Union All
Select 'textb'Select * From testDelete a From test a left outer join test b on a.tstr=b.tstr Where a.tid>b.tidSelect * From testDrop Table test/*
tid tstr
----------- -----
1 texta
2 textb
3 texta
4 textb(所影响的行数为 4 行)
tid tstr
----------- -----
1 texta
2 textb(所影响的行数为 2 行)
*/