标题:这样写错在哪?(游标)
取消只看楼主
killer_l
Rank: 2
等 级:新手上路
威 望:3
帖 子:1139
专家分:0
注 册:2007-5-25
 问题点数:0 回复次数:1 
这样写错在哪?(游标)
程序代码:
declare @xx char(20),@yy char(20) ,@zz char(20)
declare zz cursor for
select 员工号,姓名,缺勤名称 from JBQK a, QQLX b where a.缺勤类型 = b.缺勤类型 and a.缺勤天数 = 1
print '缺勤天数为1天的'
open zz
fetch next from zz into @xx,@yy,@zz
while @@fetch_status = 0
begin 
    fetch next from zz into @xx,@yy,@zz
    print '员工号'++'              '+'姓名'+'               '+'缺勤名称'
        print @xx +@yy + @zz
end
close zz

declare yy cursor for
select 员工号,姓名,缺勤名称 from JBQK a, QQLX b where a.缺勤类型 = b.缺勤类型 and a.缺勤天数 = 2
print '---------------------'
print '缺勤天数为2天的'
open yy
fetch next from yy into @xx,@yy,@zz
while @@fetch_status = 0
begin 
    fetch next from yy into @xx,@yy,@zz
    print '员工号'++'              '+'姓名'+'               '+'缺勤名称'
        print @xx +@yy + @zz
    
    
end
close yy 
结果查出来两个结果一样的
员工号              姓名               缺勤名称
5                   邓刚                病假   
---------------------
缺勤天数为2天的
员工号              姓名               缺勤名称
4                   张晓华              事假               
员工号              姓名               缺勤名称
4                   张晓华              事假      
搜索更多相关主题的帖子: 游标 
2007-11-29 19:05
killer_l
Rank: 2
等 级:新手上路
威 望:3
帖 子:1139
专家分:0
注 册:2007-5-25
得分:0 
谢谢两位了

2007-11-30 16:01



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-189356-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.114058 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved