alter table 表 add newfield int identity(1,1)delete 表
where newfield not in(
select min(newfield) from 表 group by user_id,date,sl
)alter table 表 drop column newfield
where newfield not in(
select min(newfield) from 表 group by user_id,date,sl
)alter table 表 drop column newfield
truncate table 表
insert 表 select * from #temp
drop table #temp
drop table yourtable
exec sp_rename newtable,yourtable
请问一下大力:我用以上方法与用你的第一种方法在性能上有什么缺点?
我是说
: pengdali(大力) ( ) 信誉:376 alter table 表 add newfield int identity(1,1)delete 表
where newfield not in(
select min(newfield) from 表 group by user_id,date,sl
)alter table 表 drop column newfield
方法很好
FROM taable L
JOIN table R
ON L.user_id " = R.user_id
AND L.newfield > R.newfield alter table 表 drop column newfield
FROM taable L
JOIN table R
ON L.user_id = R.user_id
AND L.newfield > R.newfield alter table 表 drop column newfield
你的做法会把所有重复的行删掉。
但是如果表中有不重复的行和有重复的行?
这时应该怎么办?