博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
存储过程
阅读量:6862 次
发布时间:2019-06-26

本文共 1536 字,大约阅读时间需要 5 分钟。

--无参数无返回值create proc plasbeginselect*from Studentendexec pldrop proc pl
--有参数无返回值create proc p2@banj_id char(10), @Ssex char(2)asbeginselect*from Student where Class=@banj_id and Ssex=@Ssex enddrop proc p2exec p2 95031,男
--默认参数无返回值create proc p3@Ssex char(2)=男asselect*from Student where Ssex like @Ssex+'%'exec p3
--有返回值无参数create proc p4@Sno char(10) outputas beginselect @Sno=Sname from Student where Sno=105enddeclare @rt char(10)exec p4 @rt outputprint @rt
--有返回值有参数create proc p5@a int,@b int,@c int outputasbeginset @c=@a+@benddeclare @rt intexec p5 1,2,@rt outputprint @rt
--返回值return写法,只能返回单个数据值alter proc p5@a int,@b intasbeginreturn @a+@benddeclare @rt intexec @rt=p5 1,2print @rt
--动态查询--解析执行语句exec('select*form Student')create proc p6@tablename varchar(15)asbeginexec('select*from '+@tablename)enddrop proc p6exec p6 'Student'create proc p7@tablename char(10),@column char(10),@value char(10)asdeclare @query varchar(255)select @query='select*from '+@tablename+' where '+@colum=@valueexec (@query)exec p7 student,class,95033
--标量函数返回唯一数据值create function f1 ()returns intasbeginreturn 1endselect dbo.f1()create function f2(@a int ,@b int)returns intas beginreturn @a+@benddeclare @rt intselect @rt=dbo.f2(1,2)print @rt
--内嵌表值函数create function f3()returns tableasreturn(select *from student) select*from dbo.f3()--多语句表值函数alter function f4()returns @t table(sno int,sname varchar(20))asbegininsert into @t select top 2 sno,sname from studentreturnendselect*from dbo.f4()

 

转载于:https://www.cnblogs.com/liuyudong0825/p/4764505.html

你可能感兴趣的文章
iOS_nil、Nil、NULL、NSNull的区别
查看>>
bzip2 安装
查看>>
java clone
查看>>
[C++基础]010_C函数的古老定义方式(K&R style definition)
查看>>
lstm caffe几个变量的含义
查看>>
路由器如何当交换机使用
查看>>
多线程知识点整理
查看>>
BZOJ 2844 albus就是要第一个出场 ——高斯消元 线性基
查看>>
BZOJ 2946 [Poi2000]公共串 ——后缀自动机
查看>>
命令模式-3.撤销与重做的实现
查看>>
架构师之路--应用架构的选型和dubbo
查看>>
JAVA学习--子类对象实例化的全过程
查看>>
Python学习过程(二)
查看>>
[解题报告]HDU 1005 Number Sequence
查看>>
725. Split Linked List in Parts
查看>>
Android对象类系列化public class User implements Parcelable
查看>>
jq插件
查看>>
从零开始学习Sencha Touch MVC应用之十八
查看>>
博客园是不是应该取消反对按钮或者改进反对按钮
查看>>
重写equals()方法时,需要同时重写hashCode()方法
查看>>