pengdali(大力 V3.0) wzh1215(四脚蛇) zjcxc(邹建) 昨天的问题再加一个条件order by dwbh 就不会了!!

zhuimeng313 2003-12-08 11:05:19
http://expert.csdn.net/Expert/topic/2531/2531224.xml?temp=.2511713

就是在递增是按照单位编号 order by dwbh 怎么实现此功能
...全文
48 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
小光快闪 2003-12-08
  • 打赏
  • 举报
回复
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('数据库中没有新参加社会化发放的人员,不须设置!');
wzh1215 2003-12-08
  • 打赏
  • 举报
回复
要不你在dwbh上建立聚集索引也行!
wzh1215 2003-12-08
  • 打赏
  • 举报
回复
--用个临时表吧
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
Rotaxe 2003-12-08
  • 打赏
  • 举报
回复
也许应该是
declare @yhzh int
SELECT @yhzh=max(yhzh)
FROM shbx2.人员情况表
WHERE (if_shff = '是') and (gzzk='离休' or gzzk='退休')

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
Rotaxe 2003-12-08
  • 打赏
  • 举报
回复
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 就可以了

zjcxc 元老 2003-12-08
  • 打赏
  • 举报
回复
将你的表结构贴出来.
victorycyz 2003-12-08
  • 打赏
  • 举报
回复
update与用于select查询的order by 不能同时使用。

34,874

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧