先靠一下自己。
当我做多了ORACLE时,我就忘了SQL的储存过程可以返回数据集这个事实了。
。。。。。。。。。。。。。。。。
Create procedure test
@t1 int,
@t2 nvarchar(200) out
as
set t2=’这个是输出参数’;
go
调用
declare @out_t2 nvarchar(200);
exec test 1,@out_t2;
select @out_t2;
输出:
这个是输出参数
------
也可以定义一个接收参数,接收存储过程的成功与否的默认返回值(这会是一个整数,0 是无错误执行,其它数为错误代码!)
declare @val int;
declare @out_t2 nvarchar(200);
exec @val = test 1,@out_t2;
select @out_t2,@val;
除了这些简单参数,存储过程还可以直接返回一个数据集
Create procedure test
@t1 int
as
select * from table_2;
go
执行:
exec test 1;
结果,就是table_2表的集合.
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/176599.html原文链接:https://javaforall.net
