T-SQL 有参数存储过程的创建与执行
use StudentManager
go
if exists(select * from sysobjects where name='usp_ScoreQuery2')
drop procedure usp_ScoreQuery2
go
--创建带参数的存储过程
create procedure usp_ScoreQuery2
@CSharp int,
@DB int
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
go
--调用带参数的存储过程
exec usp_ScoreQuery2 60,65 --按照参数顺序赋值
exec usp_ScoreQuery2 @DB=65,@CSharp=60 --参数顺序可以调换
为参数赋默认值
use StudentManager
go
if exists(select * from sysobjects where name='usp_ScoreQuery3')
drop procedure usp_ScoreQuery3
go
--创建带参数的存储过程
create procedure usp_ScoreQuery3
@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
go
--调用带参数的存储过程
exec usp_ScoreQuery3 65 --第二个参数没有赋值,则默认
exec usp_ScoreQuery3 @DB=65
exec usp_ScoreQuery3 default,65 --不使用显示方式赋值
exec usp_ScoreQuery3 --两个参数都是用默认参数
T-SQL 有参数存储过程的创建与执行的更多相关文章
- 2019-03-19 SQL Server简单存储过程的创建 删除 执行
--创建名为 Get 的有输入参数的存储过程 create proc Get --设置默认值 @TrustId int ='001' as begin select * from [DealStruc ...
- ORACLE存储过程的创建和执行的简单示例和一些注意点
此示例的主要目的主要是为了了解在PL/SQL环境下怎么创建和执行存储过程. 存储过程所涉及的DataTable: 第一步:创建游标变量 游标是ORACLE系统在内存中开辟的一个工作区,主要用来存储SE ...
- SQL Server中存储过程的创建命令
Create Proc 存储过程名称 ( @参数1 参数类型, @参数2 参数类型, ... ... --最后一行参数,别加逗号了,加逗号的意思是表示后面还有参数 ) AS 需要执行的SQL命令 GO ...
- sqlserver 带输出参数的存储过程的创建与执行
创建 use StudentManager go if exists(select * from sysobjects where name='usp_ScoreQuery4') drop proce ...
- T-SQL 无参数的存储过程的创建和执行
use StudentManager go if exists(select * from sysobjects where name='usp_ScoreQuery') drop procedure ...
- SQL Server--一个存储过程对同一个字段执行两种Update
需求: 服务器程序被界面点击"置零"按钮后,所有未完成的任务的状态都置为异常结束. 但分两种情况: 0<=Status<40状态为未完成的任务1,其异常结束状态为50 ...
- SQL Server 【附】创建"商品管理数据库"、"学生选课数据库"的SQL语句
附:(创建“商品管理数据库”的SQL语句) --建立"商品管理数据库"数据库-- create database 商品管理数据库 on(name='商品管理数据库_m', file ...
- SQL Server 2008 存储过程,带事务的存储过程(创建存储过程,删除存储过程,修改存储过
SQL Server 2008 存储过程,带事务的存储过程(创建存储过程,删除存储过程,修改存储过 存储过程 创建存储过程 use pubs --pubs为数据库 go create proc ...
- 在sql server中建存储过程,如果需要参数是一个可变集合怎么处理?
在sql server中建存储过程,如果需要参数是一个可变集合的处理 原存储过程,@objectIds 为可变参数,比如 110,98,99 ALTER PROC [dbo].[Proc_totalS ...
随机推荐
- centos7配置lamp成功安装过
linux+apache+mysql/mariadb+php 首先apache的安装: yum install httpd 接着mysql/mariadb的安装: yum install mysql ...
- MySQL Replication--复制异常1
============================================== 问题描述: 1.从库环境:MySQL 5.7.19,主从都开启GTID模式 2.MySQL数据目录所有者被 ...
- HBase Filter
Filter CompareFilter 是高层的抽象类,下面我们将看到他的实现类和实现类代表的各种过滤条件 RowFilter,FamliyFilter,QualifierFilter,ValueF ...
- C# 自动升级
自动更新的软件的目的在于让客户不在为了寻找最新软件花费时间.也不用去到开发商的网站上查找.客户端的软件自动会在程序启动前查找服务器上最新的版本.和自己当前软件的版本比较,如果服务器的是最新版本.客户端 ...
- oracle-rman-2
归档日志的备份 RMAN> list archivelog all;show archivelog deletion policy;configure archivelog deletion p ...
- Fedora Redhat Centos 有什么区别和关系?
Fedora Redhat Centos 有什么区别和关系? 经常看到有人讨论服务器的操作系统,比如 Readhat 和 Centos,还有 Ubuntu Server. 可能 Ubuntu Serv ...
- centos7数据库连接使用127.0.0.1报permission denied,使用localhost报No such file or directory
安装lamp环境后,测试数据库连接. 当host使用127.0.0.1时,报错:(HY000/2002): Permission denied. 把host换成localhost后,又报错:SQLST ...
- 六、springboot(三)配置双数据源
1.目录结构 2.jdbc.properties配置 #db houge spring.datasource.houge.jdbc-url=jdbc:oracle:thin:@:ORCL spring ...
- struts2+dojo实现datagrid
ACTION: package test.action; import java.util.ArrayList; import java.util.HashMap; import java.util. ...
- JFrame添加组件
jframe.add(button) 与 jframe.getContentPane().add(button) 结果是一样的, 都是将组件添加到jframe自带的容器ContentPane中.