alter table t add id int identity(1,1)
delete from t where id not in (select min(id) from t group by 序号)
alter table t drop column id
delete from t where id not in (select min(id) from t group by 序号)
alter table t drop column id
解决方案 »
- 关于replace
- 求一条汇总记录SQL语句
- sql两个不同版本的实例
- 想要迁移数据库服务器,有无好建议? -- 内详请高手 --
- server 2000 一个表的字段属性是image,内容一栏只显示<binary>.请问如何能看到其内容?
- 为何SQL Server无法正常运行?
- MSSQL多表查询(一个基表,两个求和表)问题
- sql server2005, 作表更改等操作时出现".net framework data provider is not found..."字样的错误提示
- 有个朋友说他人数据库到1g大后,就存到其它目录去了,怎么回事??我也不是很懂sql2000
- 存储过程里能用循环语句吗?怎么用?
- 触发器的问题,请各位大侠帮忙哦。
- 表名为动态获得的问题
go
delete from t where id not in (select min(id) from t group by un)
alter table t drop column id
go
delete from t where id not in (select min(id) from t group by un)
go
alter table t drop column id
go
select 序号 from 表 group by 序号 having count(*)>1
alter table 表 add id int identity(int,1,1)
godelete a
from 表 a left join(
select id=min(id) from 表 group by 序号
)b on a.id=b.id
where b.id is null
goalter table 表 drop column id
truncate table table1
insert into table1 select * from temp
drop table temp
alter table 表 add id int identity(1,1)
godelete a
from 表 a left join(
select id=min(id) from 表 group by 序号
)b on a.id=b.id
where b.id is null
goalter table 表 drop column id
Create @temp table(序号)INSERT INTO @temp
SELECT 序号 from T_table group by 序号 having count(*)>1DELETE T_table
WHERE 序号 IN (SELECT 序号 from T_table group by 序号 having count(*)>1)INSERT INTO T_table
SELECT * from @temp
Create @temp table(序号)換成Decimal @temp table(序号 Bigint)
select distinct * into b from adelete from ainsert into a select * from b若有ID:delete from a where id not in(select min(id) from a group by col having count(*)>1)