创建

use StudentManager
go
if exists(select * from sysobjects where name='usp_ScoreQuery4')
drop procedure usp_ScoreQuery4
go
create procedure usp_ScoreQuery4 --创建带参数的存储过程
@AbsentCount int output,--缺考总人数
@FailedCount int output,--不及格总人数
@CSharp int=60,
@DB int=60
as
select Students.StudentId,StudentName,C#=CSharp,DB=SQLServerDB
from Students
inner join ScoreList on Students.StudentId=ScoreList.StudentId
where CSharp<@CSharp or SQLServerDB<@DB --显示结果列表
select @AbsentCount=count(*) from Students
where StudentId not in(select StudentId from ScoreList) --查询缺考总人数
select @FailedCount=count(*) from ScoreList
where CSharp<@CSharp or SQLServerDB<@DB --查询不及格总人数
go

执行

 use StudentManager
go
--调用带参数的存储过程
declare @AbsentCount int,@FailedCount int --首先定义输出参数
exec usp_ScoreQuery4 @AbsentCount output,@FailedCount output
--使用反馈的结果
select 缺考总数=@AbsentCount,不及格总数=@FailedCount

sqlserver 带输出参数的存储过程的创建与执行的更多相关文章

  1. sqlserver 带输出参数的存储过程

    --创建存储过程create procedure proc_stu@sname varchar(20),@pwd varchar(50),@flag bit outputasif exists(sel ...

  2. c#调用带输出参数的存储过程

    sql server中编写一个存储过程: CREATE PROCEDURE ProGetPWD @username varchar(20), @password varchar(20) OUTPUT ...

  3. T-SQL 无参数的存储过程的创建和执行

    use StudentManager go if exists(select * from sysobjects where name='usp_ScoreQuery') drop procedure ...

  4. SqlDataReader执行带输出参数存储过程 错误分析

    在上一篇随笔:SqlDataReader读取分页数据,pageCount你是肿么了? 遇到了很让人头疼的问题:SqlDataReader执行带输出参数的存储过程总是获取不到输出参数的正确值.这里将解决 ...

  5. C# 调用带输入输出参数的存储过程

    //调用存储过程执行类似于2//select count(*) from userinfo where username=username and pwd=pwd and grade=grade3// ...

  6. C#调用存储过程带输出参数或返回值

    CREATE PROCEDURE [dbo].[GetNameById] @studentid varchar(8), @studentname nvarchar(50) OUTPUT AS BEGI ...

  7. [转] ADO.NET调用存储过程带输出参数或返回值

    CREATE PROCEDURE [dbo].[GetNameById] @studentid varchar(), @studentname nvarchar() OUTPUT AS BEGIN S ...

  8. 创建有输出参数的存储过程并在c#中实现DataGridView分页功能

    不足之处,欢迎指正! 创建有输出参数的存储过程 if exists(select * from sysobjects where name='usp_getPage1') drop procedure ...

  9. EF执行存储过程(带输出参数)

    1.不含动态sql.带输出参数存储过程调用实例 1.存储过程代码:   2.EF自动生成代码(包括对应ObjectResult的实体模型): 3.调用存储过程代码实例: 总结: ObjectParam ...

随机推荐

  1. Git:一个简单示例

    初始状态:两个分支master/dev都只有一个文件readme.txt 待解决问题:在master分支新增文件,并且修改readme.txt文件,将上述操作同步至远程master分支,最后同步到de ...

  2. Ubuntu 16.04+GTX970 黑屏无法安装解决方法

    参考http://www.linuxidc.com/Linux/2017-01/139318.htm http://blog.sciencenet.cn/blog-655584-877622.html ...

  3. 秒懂 this(带你撸平this)

    本文讲述只针对浏览器环境. 一:全局执行 console.log(this); // Window 可以看出在全局作用域中 this 指向当前的全局对象 Window. 二:函数中执行 1. 非严格模 ...

  4. redis 版的 hello world

    为 redis 添加一个命令,效果如下图: 在 Server.h 中加入命令处理函数的声明: void meCommand(client *c); 在 Server.c 的命令表中加入: struct ...

  5. QLineSeries QChartView 生成折线

    效果图 // 创建折线上点的序列 QLineSeries *splineSeries = new QLineSeries(); //QSplineSeries *splineSeries = new ...

  6. 如何使用require.js?

    最近几天在学习一个javascript库require.js,也看了一些相关的教学视频,这里推荐一下幕课网阿当老师的<阿当大话西游之Web组件>的教学视频,一整套看下来,参照视频里面的de ...

  7. css美化页面

    css美化页面 如果在我们一行文字中,想让某个文字凸显出来,使用span! 1.字体样式 font-style:字体的风格 italic normal font-weight:字体的粗细 normal ...

  8. MySQL-8.0.15在Win10和Ubuntu上安装&使用

    一.Windows环境下安装: 1.下载MySQL压缩包 官网地址:https://dev.mysql.com/downloads/mysql/ 点击直接下载: 2.解压到本地目录,并添加一个配置文件 ...

  9. centos7下stf安装介绍(一)----环境搭建

    重要:node version需要8.x.x 介绍 stf 全称 Smartphone Test Farm ,一款WEB 端移动设备批量管理工具(Remote control all your Sma ...

  10. laravel 常用命令

    1.创建控制器 php artisan make:controller ArticleController // 带 restful 风格 php artisan make:controller Ar ...