
1、再建立一个专门用来存放记录号的字段,比如 RecordNo, 添加记录时可以用 MAX(recordNO)+1 的方法。当要删除某条记录时,比如这条记录的recordNo=6,我们用
delete from table where recordNo=6update table set recordno=recordno-1 where recordno>6
2、在表中不存放记录号的数据,用sql查询自动生成
select [id],a,b,c,(select count(*) from table table2 where table2.[id]<=table1.[id]) as recordno from table table1 order by [id]其中 [id] 字段为自动编号字段
删除后重新排序编号? 如果是的话可以删完后重新查询按编号排序 select 编号 from " &table &" order by 编号"然后 for 循环遍历数据集
for i =1 to rs.recordcount
rs.fields("编号")=i
rs.update
next i
最简单的办法,新增一个IT IDENTITY(1,1)列,==>其会自应在当前的排序情况下生成序列数字. 然后,删除原先的列。 具体的语句使用Alter Table,很简单的,Lz可自行尝试。欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)