---=====存储过程可以设返回值,但要设批处理才能获得返回值的对应标量值====------
USE Student_Back
GO
CREATE PROCEDURE Stu_Age
(@num nvarchar(100))
--@returnVaule int out
AS
BEGIN
DECLARE @i int
SELECT S_NUMBER,datediff(year,BIRTHDAY,getdate()) as 年龄
FROM [Student_Back].[dbo].[T_Student] where S_NUMBER=@num
set @i=@@error
return 3
END
GO
declare @re int;
exec @re=[dbo].[Stu_Age] 'B0451101';
select @re as ret;
GO
本文展示了一个使用SQL Server创建存储过程的例子,该过程接受一个参数并返回一个值。通过示例代码,读者可以了解如何定义和调用带有返回值的存储过程。

被折叠的 条评论
为什么被折叠?



