蓝狗happy 2024-05-31 23:16 采纳率: 50%
浏览 9
已结题

SQL的存储过程不能输出结果

存储过程代码可以正常执行,但是好像不能输出结果,数据并没有插入到表中去

create table Lisan(grade char(40) ,num int)
create procedure L2
as
begin
  declare
    @0to60 smallint,
    @60to70 smallint,
    @70to80 smallint,
    @80to90 smallint,
    @90to100 smallint
  select
     @0to60 =0,
    @60to70 =0,
    @70to80 =0,
    @80to90 =0,
    @90to100 =0
    
    select  @0to60 =count(*)
    from sc
    where grade <=60 and cno='8'

    select @60to70 = count(*)
    from sc
    where grade > 60 and grade <=70 and cno='8'

    select @70to80 = count(*)
    from sc
    where grade > 70 and grade<=80 and cno='8'
    
    select @80to90 = count(*)
    from sc
    where grade > 80 and grade <= 90 and cno='8'

    select @90to100 = count(*)
    from sc
    where grade>90 and grade<=100 and cno='8'

    insert 
    into Lisan 
    values('<=60',@0to60)
    insert 
    into Lisan 
    values('60-70',@60to70)
    insert 
    into Lisan 
    values('70-80',@70to80)
    insert 
    into Lisan 
    values('80-90',@80to90)
    insert 
    into Lisan 
    values('90-100',@90to100)

    select '90to100' ,@90to100
    select '80to90' ,@90to100
    select '70to80' ,@90to100
    select '60to70' ,@90to100
    select '0to60' ,@90to100

end
go

img

  • 写回答

4条回答 默认 最新

  • svygh123 2024-06-01 00:25
    关注

    你只是创建了表和存储过程,并没有调用存储过程。
    调用一下存储过程:

    EXEC L2;
    

    然后查询一下表

    select * from Lisan;
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

问题事件

  • 系统已结题 6月12日
  • 已采纳回答 6月4日
  • 创建了问题 5月31日

悬赏问题

  • ¥15 pcl运行在qt msvc2019环境运行效率低于visual studio 2019
  • ¥15 MAUI,Zxing扫码,华为手机没反应。可提高悬赏
  • ¥15 python运行报错 ModuleNotFoundError: No module named 'torch'
  • ¥100 华为手机私有App后台保活
  • ¥15 sqlserver中加密的密码字段查询问题
  • ¥20 有谁能看看我coe文件到底哪儿有问题吗?
  • ¥20 我的这个coe文件到底哪儿出问题了
  • ¥15 matlab使用自定义函数时一直报错输入参数过多
  • ¥15 设计一个温度闭环控制系统
  • ¥100 rtmpose姿态评估