linear_max() Scalar Function : Utility function « Procedure Function « SQL Server / T-SQL Tutorial






6>  CREATE FUNCTION dbo.linear_max
7>  (
8>    @arg1 AS int,
9>    @arg2 AS int
10>  )
11>  RETURNS int
12>  AS
13>  BEGIN
14>    RETURN CASE
15>             WHEN @arg1 >= @arg2 THEN @arg1
16>             WHEN @arg2 >  @arg1 THEN @arg2
17>             ELSE NULL
18>           END
19>  END
20>  GO
1>
2> SELECT
3>   dbo.linear_max(1, 2)
4>
5>  drop function dbo.linear_max
6>  GO

-----------
          2

(1 rows affected)
1>
2>








21.6.Utility function
21.6.1.Scalar Functions
21.6.2.Format a date
21.6.3.linear_max() Scalar Function
21.6.4.The linear_min Scalar Function
21.6.5.Changing Character Values to Proper Case with user-defined functions
21.6.6.if an int odd