if noteCount >0 then
begin
while not ADODataModule.ADODataSet1.Eof do
begin
maxYhzh:= maxYhzh+1;
ADODataModule.ADODataSet1.Edit;
ADODataModule.ADODataSet1.FieldByName('yhzh').AsInteger:=maxYhzh;
ADODataModule.ADODataSet1.Post;
ADODataModule.ADODataSet1.next;
// showmessage('maxYhzh ='+inttostr(maxYhzh));
end;
end
else
showmessage('数据库中没有新参加社会化发放的人员,不须设置!');
--用个临时表吧
select * into #aa from 你的表 where id is null order by dwbh
--再对临时表进行处理
declare @i int
set @i=0
update #aa
set @i=@i+1,yhzh=(select max(id) from #aa)+@i
--删除原表中yhzh号为空的记录
delete from 你的表 where yhzh is null
--把临时表的数据插入
insert 你的表
select * from #aa
declare @yhzh int
SELECT @yhzh=max(yhzh)
FROM shbx2.人员情况表
WHERE (if_shff = '是') and (gzzk='离休' or gzzk='退休') and (yhzh is null)
if @yhzh is null set @yhzh=0
update shbx2.人员情况表 set @yhzh=@yhzh+1,yhzh=@yhzh
WHERE (if_shff = '是') and (gzzk='离休' or gzzk='退休') and (yhzh is null) order by dwbh
后面加上order by dwbh 就可以了