declare @tbl table(id int identity(1,1),nid int) --定义表变量
insert into @tbl(nid) select [id] from sfxm order by xh asc
update sfxm set sfxm.xh=s.[id] from sfxm,@tbl s where sfxm.[id]=s.nid
insert into @tbl(nid) select [id] from sfxm order by xh asc
update sfxm set sfxm.xh=s.[id] from sfxm,@tbl s where sfxm.[id]=s.nid