Monday 1 December 2014

Execute a SQL function

USE AdventureWorks2012;
GO
-- Declares a variable and sets it to zero.
-- This variable is used to return the results of the function.
DECLARE @ret nvarchar(15)= NULL; 

-- Executes the dbo.ufnGetSalesOrderStatusText function.
--The function requires a value for one parameter, @Status. 
EXEC @ret = dbo.ufnGetSalesOrderStatusText @Status= 5; 
--Returns the result in the message tab.
PRINT @ret;

No comments:

Post a Comment