1.delete top N from tb 2.select * into xx from tb where 很特殊=true truncate table tb insert into tb select * from xx
delete a from ta a where exists(select top N * from ta where a.id = id) update a set col = b.col from a right join b on b.id = a.id where b......... = ??
create table tb (id int) insert tb select 1 union all select 2 union all select 3set rowcount 1 --将1改为你的n delete from tb set rowcount 0select * from tbdrop table tb 第二问,不明你意。
--1 delete from tab where id in (select top n id from tab order by id)
select identity(int,1,1) as id ,* into tmp from tablename drop table tmp where id <=n ---- 請問怎樣刪除某數據表的前n條記錄. sp_rename 'tmp','tablename'
---如果没有序号列! select identity(int,1,1) as id ,* into tmp from tablename drop table tmp where id <=n ---- 請問怎樣刪除某數據表的前n條記錄. drop table tablenamesp_rename 'tmp','tablename'
delete top N from tb 這一行不可以執行啊
delete a from ta a where exists(select top N * from ta where a.id = id) 這一行肯定不行id要是主鍵才行
2.select * into xx from tb where 很特殊=true
truncate table tb
insert into tb select * from xx
from ta a
where exists(select top N * from ta where a.id = id)
update a
set col = b.col
from a
right join b
on b.id = a.id
where b......... = ??
insert tb select 1 union all select 2 union all select 3set rowcount 1 --将1改为你的n
delete from tb
set rowcount 0select * from tbdrop table tb
第二问,不明你意。
delete from tab
where id in (select top n id from tab order by id)
select identity(int,1,1) as id ,* into tmp from tablename drop table tmp where id <=n ---- 請問怎樣刪除某數據表的前n條記錄. drop table tablenamesp_rename 'tmp','tablename'
這一行不可以執行啊
from ta a
where exists(select top N * from ta where a.id = id)
這一行肯定不行id要是主鍵才行