存储过程

来源:互联网 发布:aix删除网络配置 编辑:程序博客网 时间:2024/05/17 10:53

use yuyongTest;

go

 

--定义一个存储过程,给这个存储过程传入int一个参数,这个存储过程将为一个nvarchar(50)类型的参数赋值(以作为结果)

create procproc_getStudentName(@numint,@namenvarchar(50)out)

as

    select @name=namefrom student where number=@num;

go

--定义一个nvarchar(50)类型的变量,接受这个存储过程的赋值(相当于返回结果)

declare @getName nvarchar(50);

--执行存储过程,传入输入参数和需要接收结果的变量

exec proc_getStudentName62,@getName out;

select @getName;

 

select *from student where number=62

 

结果如下


0 0
原创粉丝点击