4> CREATE FUNCTION dbo.ufnIsOdd (@n int = 5)
5> RETURNS bit
6> AS
7> BEGIN
8> RETURN (@n % 2)
9> END
10> GO
1>
2> CREATE PROCEDURE usp_NumberIsOdd
3> @n int = 5
4> AS
5> SELECT @n 'Number', @n % 2 'Is_odd = 1'
6> GO
1>
2> DECLARE @numb int
3>
4> SELECT @numb 'Number', dbo.ufnIsOdd (@numb) 'Is_odd = 1'
5> SELECT @numb 'Number', dbo.ufnIsOdd (DEFAULT) 'Is_odd = 1'
6> SET @numb = 6
7> SELECT @numb 'Number', dbo.ufnIsOdd (@numb) 'Is_odd = 1'
8> GO
Number Is_odd = 1
----------- ----------
NULL NULL
(1 rows affected)
Number Is_odd = 1
----------- ----------
NULL NULL
(1 rows affected)
Number Is_odd = 1
----------- ----------
6 0
(1 rows affected)
1>
2> drop FUNCTION dbo.ufnIsOdd;
3> GO
1>
2> drop PROCEDURE usp_NumberIsOdd;
3> GO