Shantanu Gupta
Shantanu Gupta

Reputation: 21108

Can we create scalar valued function in SQL Server as deterministic and precise?

Can we create a function in SQL Server to be deterministic and precise without CLR?

CREATE FUNCTION ufn_max_smalldatetime ()
RETURNS SMALLDATETIME
    WITH SCHEMABINDING
AS 
    BEGIN
        RETURN CAST('2079-06-06' AS SMALLDATETIME)
    END

Upvotes: 1

Views: 608

Answers (1)

Kuba Wyrostek
Kuba Wyrostek

Reputation: 6221

As far as I know SQL Server determines itself whether your function is deterministic and/or precise. Try running the following queries and see what you get:

SELECT OBJECTPROPERTYEX(OBJECT_ID('dbo.ufn_max_smalldatetime'), 'IsDeterministic')

SELECT OBJECTPROPERTYEX(OBJECT_ID('dbo.ufn_max_smalldatetime'), 'IsPrecise')

Upvotes: 1

Related Questions