惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

aimingoo的专栏
aimingoo的专栏
博客园 - 三生石上(FineUI控件)
GbyAI
GbyAI
大猫的无限游戏
大猫的无限游戏
M
MIT News - Artificial intelligence
Microsoft Azure Blog
Microsoft Azure Blog
月光博客
月光博客
Engineering at Meta
Engineering at Meta
I
InfoQ
T
Tailwind CSS Blog
N
Netflix TechBlog - Medium
S
SegmentFault 最新的问题
H
Help Net Security
博客园 - 【当耐特】
WordPress大学
WordPress大学
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
美团技术团队
博客园 - 叶小钗
T
The Blog of Author Tim Ferriss
腾讯CDC
雷峰网
雷峰网
Martin Fowler
Martin Fowler
The GitHub Blog
The GitHub Blog
D
Docker

博客园 - FilyCks

SQL动态条件查询例子 日期格式化函数 解决日志文件满造成的无法写入问题 数据库的日志文件 Delphi制作DLL SQLSERVER 日期函数及取当天数据 SQL语句导入导出大全 日期数据处理 按时间段统计数据(1) FastReport(5) FastReport(4) FastReport(3) FastReport(2) FastReport(1) FastReport 的初学感悟 查询表(个人笔记) 图片转换和读取(个人笔记) 游标的一些例子 自己研究出来的第一个游标
游标嵌套(个人笔记)
FilyCks · 2008-03-13 · via 博客园 - FilyCks


create table #temp(tem_archno varchar(50),tem_pages int,tem_org int,tem_copy1 int)
declare @temp_archno varchar(50) 
declare @temp_pages int
declare @temp_org int
declare @temp_iscopy bit
declare @temp_iscopy1 int
                
declare mycursor cursor for select archno,archorgpages from archflow_t where

archbatchno='L20080312-01'order by archno 

open mycursor                  

fetch next from mycursor  into @temp_archno,@temp_pages  

while(@@fetch_status=0)   
begin
   set @temp_iscopy1=0
   declare mycursor1 cursor for select iscopy from imageproperty_t where archno=@temp_archno
   open mycursor1
   fetch next from mycursor1  into @temp_iscopy               

     
   while(@@fetch_status=0)
   begin
 
  if @temp_iscopy<>0
  set @temp_iscopy1=@temp_iscopy1+1
  fetch next from mycursor1 into @temp_iscopy
   end
   set @temp_org=@temp_pages-@temp_iscopy1
   insert into #temp values(@temp_archno,@temp_pages,@temp_org,@temp_iscopy1)
   fetch next from mycursor into @temp_archno,@temp_pages
   close mycursor1  
   deallocate mycursor1
end

close mycursor


select * from #temp order by tem_archno