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