[SQL]從預存程序傳回資料, PROCEDUE RETURN VALUE

  • 748
  • 0
  • 2015-01-09

摘要:[SQL]從預存程序傳回資料, PROCEDUE RETURN VALUE

從微軟參考來的

以下是PROCEDUE的部分


use Northwind
CREATE PROCEDURE uspProcReturnValue
@LastName nvarchar(50),
@Title nvarchar(100) OUTPUT
AS  

    SET NOCOUNT ON;            
    SELECT TOP 1  @Title=Title FROM Employees
    where LastName = @LastName
RETURN
GO

以下是引用此PROCEDURE的部分


DECLARE @outPutTitle varchar(100) 
exec uspProcReturnValue 'Davolio',@Title = @outPutTitle OUTPUT
print(@outputTitle);