SQL常有语句

1.查询记录中的重复字段

select usid
from qd01
group by usid
having count(1) > 1

2.删除重复字段

alter table qd01 add newid int identity(1,1)
go
delete from qd01  where exists(select 1 from qd01 a where  a.newid>qd01.newid  and qd01.usid=a.usid)
go
alter table qd01 drop column newid
go

你可能感兴趣的:(ASP.NET,SQL语句)