触发器里写 delete from czrz where intime>(select max(intime) from (select top 5 intime from czrz order by intime) c)其中的5就是你设定的最大行数,intime就是你要进行排序的字段。czrz,就是你要删除记录的表
流星尔的方法是可行的,不过一般删除旧的记录 delete from czrz where intime<(select min(intime) from (select top 5 intime from czrz order by intime desc) c)
呵呵,蓝兄说的对,我用触发器删除刚刚插入的ID的数据,结果没有出错,还有个很好玩的现象,A表原有2000多条数据,我insert a select * from a, 结果把数据表清空了。
delete from czrz where intime>(select max(intime) from (select top 5 intime from czrz order by intime) c)其中的5就是你设定的最大行数,intime就是你要进行排序的字段。czrz,就是你要删除记录的表
delete from czrz where intime<(select min(intime) from (select top 5 intime from czrz order by intime desc) c)
结果把数据表清空了。