sqlserver 带输出参数的存储过程的创建与执行
创建
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 带输出参数的存储过程的创建与执行的更多相关文章
- sqlserver 带输出参数的存储过程
--创建存储过程create procedure proc_stu@sname varchar(20),@pwd varchar(50),@flag bit outputasif exists(sel ...
- c#调用带输出参数的存储过程
sql server中编写一个存储过程: CREATE PROCEDURE ProGetPWD @username varchar(20), @password varchar(20) OUTPUT ...
- T-SQL 无参数的存储过程的创建和执行
use StudentManager go if exists(select * from sysobjects where name='usp_ScoreQuery') drop procedure ...
- SqlDataReader执行带输出参数存储过程 错误分析
在上一篇随笔:SqlDataReader读取分页数据,pageCount你是肿么了? 遇到了很让人头疼的问题:SqlDataReader执行带输出参数的存储过程总是获取不到输出参数的正确值.这里将解决 ...
- C# 调用带输入输出参数的存储过程
//调用存储过程执行类似于2//select count(*) from userinfo where username=username and pwd=pwd and grade=grade3// ...
- C#调用存储过程带输出参数或返回值
CREATE PROCEDURE [dbo].[GetNameById] @studentid varchar(8), @studentname nvarchar(50) OUTPUT AS BEGI ...
- [转] ADO.NET调用存储过程带输出参数或返回值
CREATE PROCEDURE [dbo].[GetNameById] @studentid varchar(), @studentname nvarchar() OUTPUT AS BEGIN S ...
- 创建有输出参数的存储过程并在c#中实现DataGridView分页功能
不足之处,欢迎指正! 创建有输出参数的存储过程 if exists(select * from sysobjects where name='usp_getPage1') drop procedure ...
- EF执行存储过程(带输出参数)
1.不含动态sql.带输出参数存储过程调用实例 1.存储过程代码: 2.EF自动生成代码(包括对应ObjectResult的实体模型): 3.调用存储过程代码实例: 总结: ObjectParam ...
随机推荐
- 解決 centos -bash: vim: command not found
i. 那么如何安裝 vim 呢?输入rpm -qa|grep vim 命令, 如果 vim 已经正确安裝,会返回下面的三行代码: root@server1 [~]# rpm -qa|grep vim ...
- 协程----greenlet模块,gevent模块
1.协程初识,greenlet模块 2.gevent模块(需要pip安装) 一.协程初识,greenlet模块: 协程:是单线程下的并发,又称微线程,纤程.英文名Coroutine.一句话说明什么是线 ...
- mysql安装和初次密码修改
下载 第一步:打开网址,https://www.mysql.com,点击downloads之后跳转到https://www.mysql.com/downloads 第二步 :跳转至网址https:// ...
- jsp请求转发与重定向区别小结
1.当使用转发时,JSP容器将使用一个内部方法来调用目标页面,新的页面继续处理同一个请求,而浏览器不会知道这个过程; 2.重定向是第一个页面通知浏览器发送一个新的页面请求. 3.转发不改变URL,重定 ...
- Nearest Common Ancestors (POJ 1330)
A rooted tree is a well-known data structure in computer science and engineering. An example is show ...
- vuex-Mutation(同步)
更改 Vuex 的 store 中的状态的唯一方法是提交 mutation.Vuex 中的 mutation 非常类似于事件: 每个 mutation 都有一个字符串的 事件类型 (type) 和 一 ...
- ios 审核未通过 相机相册权限问题
苹果提交审核被打回来 附加的说明如下: We noticed that your app requests the user’s consent to access their camera but ...
- 弹性布局(Flex布局)整理
一. 弹性布局 一个好的网站都有让用户看上去很舒服的布局,一个网站的布局也会或多或少影响到它的浏览量,看完阮大神的博客,就想把弹性布局整理一下. 在平时的我们常用的布局类型有以下几种: 1.浮动+定 ...
- ASP.NET之使用Ajax实现页面异步刷新(无需刷新整个页面)
目前在使用ASP.NET技术做毕业设计,但是关于网页中的各种配置我到现在还不是很清楚,正在努力进化... 一般情况下,新建网页页面的话,应该为.aspx后缀的文件,建好之后对应一个同名的.cs文件,属 ...
- Tomcat配置虚拟主机、tomcat的日志
1.配置Tomcat的虚拟主机修改:vim /usr/local/tomcat9/conf/server.xml 添加一个虚拟主机:加入: <Host name="www.tomcat ...