begin tran
select DISTINCT [id],[name],[sex] into #temp from emply
TRUNCATE TABLE emply
INSERT INTO emply([id],[name],[sex])
select [id],[name],[sex] from #temp
commit tran
create table a(id nvarchar(10),name nvarchar(10),sex nvarchar(10))
insert into a select '001','张三','男'
insert into a select '002','李死',''
insert into a select '001','张三','男'
insert into a select '002','李死',''
insert into a select '001','张三','男'
insert into a select '002','李死',''
insert into a select '001','张三','男'
insert into a select '002','李死',''
insert into a select '001','张三','男'
insert into a select '002','李死',''
insert into a select '001','张三','男'
insert into a select '002','李死',''
go
alter table a add sid int identity(1,1)
go
delete a from a t where sid not in (select top 1 sid from a where id=t.id order by sid)
go
alter table a drop column sid
go
create table a(id nvarchar(10),name nvarchar(10),sex nvarchar(10))
insert into a select '001','张三','男'
insert into a select '002','李死',''
insert into a select '001','张三','男'
insert into a select '002','李死',''
insert into a select '001','张三','男'
insert into a select '002','李死',''
insert into a select '001','张三','男'
insert into a select '002','李死',''
insert into a select '001','张三','男'
insert into a select '002','李死',''
insert into a select '001','张三','男'
insert into a select '002','李死',''
alter table emplay sid int identity(1,1)
go
delete a
from emplay a where id not in (select top 1 sid form emplay where id=a.id order by sid)
go
alter table emplay dorp column sid