I wanted to use MOD
function in SQL Server 2008R2
and followed this link but still got the message:
'MOD' is not a recognized built-in function name.
DECLARE @m INT
SET @m = MOD(321,11)
SELECT @m
Error:
Msg 195, Level 15, State 10, Line 2
'MOD' is not a recognized built-in function name.
Why I can't use this function from the link above?
This question is related to
sql
sql-server-2008
tsql
sql-server-2008-r2
modulo
for your exact sample, it should be like this.
DECLARE @m INT
SET @m = 321%11
SELECT @m
If using JDBC driver you may use function escape sequence like this:
select {fn MOD(5, 2)}
#Result 1
select mod(5, 2)
#SQL Error [195] [S00010]: 'mod' is not a recognized built-in function name.
In TSQL, the modulo is done with a percent sign.
SELECT 38 % 5 would give you the modulo 3
It can be done using % operator. i.e. SELECT 50 % 5
Source: Stackoverflow.com