How does sql server determine if a function is deterministic or not?
Consider the following function, I think it's deterministic (as it's ultimately an integer operation), but sql server returns 0 when I call the objectproperty method on it.
Understanding how it works will help me understand why I'm wrong in my assessment of this function.
CREATE FUNCTION dbo.EndOfPreviousMonth ( @Date date )
RETURNS date
AS BEGIN
RETURN DATEADD(day, 0 - DAY(@Date), @Date);
END;
SELECT dbo.EndOfPreviousMonth('2010-01-01'); --Usage example
--Returns 0, I expected it to return 1
SELECT OBJECTPROPERTY( OBJECT_ID( 'dbo.EndOfPreviousMonth' ), 'IsDeterministic' );

DATEADDis deterministic.) – Simon Righarts Feb 9 '12 at 22:31