T-SQL 带参数存储过程
创建带参数的存储过程


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
调用时传入输入参数
use StudentManager
go
--调用带参数的存储过程
declare @AbsentCount int,@FailedCount int --首先定义输出参数
exec usp_ScoreQuery4 @AbsentCount output,@FailedCount output ,65,70
--使用反馈的结果
select 缺考总数=@AbsentCount,不及格总数=@FailedCount
T-SQL 带参数存储过程的更多相关文章
- C# 调用Mysql 带参数存储过程
使用C#调用Mysql 带参数的存储过程: 1.创建带参数的存储过程:USP_Temp_Test 2.两个参数:IN 参数为 P_XML , OUT 参数为 P_ErrorOut 3.C#代码调用该存 ...
- bat调用带参数存储过程
@bat调用sql文件 sqlplus user/pass@orcl @F:\factory.sql @将所有的存储过程封装在sql中 factory.sql:exec pro_factory(&am ...
- PYTHON 中 SQL 带参数
使用 PYTHON 的字符串填充方式 import mysql.connector sql = 'select \* from school.student where age > {age} ...
- hibernate log4j2输出sql带参数
网上有很多是输出sql ,参数以?的形式,后面输出参数binding的log,还要自己拼接特别麻烦:这里整理下输出原生sql的方法.组件是log4jdbc 1: 修改pom.xml,确定有下面的配置, ...
- SQL带参数拼接
List<SqlParameter> paras = new List<SqlParameter>(); string wherSql = PreWhereSQL + GetQ ...
- SQL Server之存储过程基础知
什么是存储过程呢?存储过程就是作为可执行对象存放在数据库中的一个或多个SQL命令. 通俗来讲:存储过程其实就是能完成一定操作的一组SQL语句. 那为什么要用存储过程呢?1.存储过程只在创造时进行编译, ...
- SQL SERVER 系统存储过程
Transact-SQL中的存储过程,非常类似于Java语言中的方法,它可以重复调用.当存储过程执行一次后,可以将语句缓存中,这样下次执行的时候直接使用缓存中的语句.这样就可以提高存储过程的性能. Ø ...
- sql的sp存储过程详解
store procedure (存储过程) http://www.cnblogs.com/xiangzhong/p/5038338.html 调优的几个关键的步骤--sp_lock,sp_who h ...
- SQL数据库—<6>存储过程
Transact-SQL中的存储过程,非常类似于Java语言中的方法,它可以重复调用.当存储过程执行一次后,可以将语句缓存中,这样下次执行的时候直接使用缓存中的语句.这样就可以提高存储过程的性能. Ø ...
随机推荐
- vue全家桶+Koa2开发笔记(7)--登陆注册功能
1 文件结构:pages中放置页面代码:server 分为 dbs 和interface两个文件夹: dbs设置有关数据库的代码:interface设置接口信息: 2.2 先看dbs的,在dbs的配置 ...
- CS程序中XML编码Encode和解码Decode
VB6的代码,原则上只要是Windows系统均可以使用此方法 Function XMLEncode(ByVal text As String) As String Dim xmldoc Set xml ...
- sql表连接方式
表连接有几种? sql表连接分成外连接.内连接和交叉连接. 一.外连接 概述: 外连接包括三种,分别是左外连接.右外连接.全外连接. 对应的sql关键字:LEFT/RIGHT/FULL OUTER ...
- centos7上部署vnc服务器并实现远程桌面
centos7上进行一下操作 [root@localhost ~]# yum install tigervnc-server -y#安装vnc服务器 Loaded plugins: fastestmi ...
- nginx屏蔽某一ip的访问
假设我们想禁止访问nginx次数最多的ip访问我们的网站 我们可以先查出那个ip访问次数最多 awk '{print $1}' nginx.access.log |sort |uniq -c|sort ...
- Cassandra Demo--Python操作cassandra
================================================================ 创建keyspace和table CREATE KEYSPACE ex ...
- Spring Boot 历史
2012年10月,Mike Youngstrom在Spring jira中创建了一个功能需求,要求在Spring框架中支持无容器Web应用程序体系结构.他建议通过main方法引导的Spring容器内配 ...
- kafka 知识点
Replica如何分布 为了尽量做好负载均衡和容错能力,需要将同一个Partition的Replica尽量分散到不同的机器.如果所有的Replica都在同一个Broker上,那一旦该Broker宕机, ...
- Elastic Story(一)
关于_all 当索引一个文档的时候,Elasticsearch 取出所有字段的值拼接成一个大的字符串,作为 _all 字段进行索引.例如,当索引这个文档时: { "tweet": ...
- c166 -div
unsigned short a=10; unsigned short b; unsigned short c;unsigned long d; b = (unsigned short)(d/2400 ...