存储过程,数据库存储过程
use yuyongTest;
go
--定义一个存储过程,给这个存储过程传入int一个参数,这个存储过程将为一个nvarchar(50)类型的参数赋值(以作为结果)
create proc proc_getStudentName(@num int,@name nvarchar(50) out)
as
select @name=name from student where number=@num;
go
--定义一个nvarchar(50)类型的变量,接受这个存储过程的赋值(相当于返回结果)
declare @getName nvarchar(50);
--执行存储过程,传入输入参数和需要接收结果的变量
exec proc_getStudentName62, @getName out;
select @getName;
select * from student where number=62
结果如下
本站文章为和通数据库网友分享或者投稿,欢迎任何形式的转载,但请务必注明出处.
同时文章内容如有侵犯了您的权益,请联系QQ:970679559,我们会在尽快处理。