Can we create scalar valued function in SQL Server

2019-07-31 09:33发布

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

1条回答
霸刀☆藐视天下
2楼-- · 2019-07-31 10:07

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')
查看更多
登录 后发表回答