收集到的:如何调用存储过程,有返回值的,有参数的,存储过程中调用存储过程。(MS SQL Server)
收集到的:如何调用存储过程,有返回值的,有参数的,存储过程中调用存储过程。(MS SQL Server)
保存下来方便学习也和大家分享下
存储过程return与output区别共同点:都返回值(但return只能返回int类型) 不同点:1.output是定义变量是不是可以返回值 2.output没有return从查询或过程中无条件退出的工功 3.return返回值在函数和过程定义时不需要用output来定义 如何在存储过程中调用存储过程?大家给个例子? ======create proc kk as begin exec jj --jj为存储过程名 end =======create table test(id int,name varchar(10)) insert into test select 1,'AAAA' insert into test select 2,'BBBB' go create procedure sp_test1(@count int output) as select @count=count(*) from test go create procedure sp_test2 as begin declare @count int exec sp_test1 @count output select @count end go exec sp_test2 go --输出结果 /* 2 */ drop procedure sp_test2,sp_test1 drop table test go---------------------1,存储过程
create proc dbo.SPd_testasbeginreturn 2;end
2,得到return 的值
DECLARE @RC intEXEC @RC = [eppoo].[dbo].[SPd_test] DECLARE @PrnLine nvarchar(4000)PRINT ''''存储过程: eppoo.dbo.SPd_test''''SELECT @PrnLine = '''' 返回代码 = '''' + CONVERT(nvarchar, @RC)PRINT @PrnLine
0 顶1 踩
原文章浏览量:4131
原文章分类:数据库
原文链接:https://www.iteye.com/blog/lizhiyu-1123633