【SQL Sever】 存储过程的创建和执行

来源:互联网 发布:linux登录oracle数据库 编辑:程序博客网 时间:2024/03/29 01:05
--无参的存储过程创建create procedure pro_test1asbeginselect * from student where stuid=1end--查询存储过程exec pro_test1DECLARE @return_value intEXEC @return_value = [dbo].[pro_test1]SELECT 'Return Value' = @return_valueGO--创建带默认参数存储过程create procedure pro_test2@stuid int =2asbeginselect * from student where stuid=@stuidend--删除存储过程drop procedure pro_test3--查询带默认参数存储过程exec pro_test2 3declare @stuid int=3exec pro_test2 @stuid--创建带输出参数的存储过程create procedure pro_test3@stuid int=4,@stuname varchar(20) output,@stubirthday varchar(20) outputasbeginselect @stuname=stuname,@stubirthday=stubirthday from student  where stuid=@stuidend--调用带输出参数的存储过程declare @stuid int,@stu_name varchar(20) ,@stu_birthday datetime exec pro_test3 @stuid=6,@stuname=@stu_name output,@stubirthday=@stu_birthday outputselect @stu_name,@stu_birthday

1 0
原创粉丝点击