Programming in MS SQL Server 2012 |
Numeric ArgumentArgument is an external data value that provided to a user-defined function to produces new scalar value or table value based on input data value. The argument variables must declares nested to CREATE FUNCTION FunctionName statement with data type and data size. If a user-defined function has more than one argument variables that need to separate by using comma symbol in the parentheses of the user-defined function. The following example describes a scalar user-defined function with numeric variables. --
Example 92 -- USE EBusiness GO IF EXISTS (SELECT *
FROM
sysobjects
WHERE
name = N'AddData')
DROP FUNCTION AddData GO CREATE FUNCTION AddData(@Number1 Decimal(5,2), @Number2 Decimal(5,2)) RETURNS Decimal(6,2) BEGIN
DECLARE @Result Decimal(6,2)
SET @Result = @Number1 + @Number2
RETURN @Result END GO --
Execute Function with Argument Data Values -- PRINT EBusiness.dbo.AddData(123.55,123.55) |
* * * * *