Invalid use of side-effecting or time-dependent operator in '%s' within a function.

Error Message:
Msg 443, Level 16, State 1, Procedure udfMyFunc, Line 5
Invalid use of side-effecting or time-dependent operator in ‘%s’ within a function.

Severity level:
16.

Description:
This error message appears when you try to use an nondeterministic operator or an operator with side-effects within a user-defined function.

Consequences:
The T-SQL statement can be parsed, but causes the error at runtime.

Resolution:
Error of the Severity level 16 are generated by the user and can be fixed by the SQL Server user. The operator must be removed from the function. If that is not possible, consider changing the function to a stored procedure, if possible.

Versions:
This error messages was introduced with SQL Server 2000.

Example(s):
CREATE FUNCTION dbo.udfMyFunc()
RETURNS FLOAT
AS
BEGIN
 RETURN RAND()
END
GO

Remarks:
In the above example we use the nondeterministic RAND() function inside a UDF. This raises the error.
The classification of what is considered “deterministic” and what is “nondeterministic” is flowing. In SQL Server 2000, for example, you couldn’t use GETDATE() inside a UDF, while this is allowed in SQL Server 2005. When in doubt consult the BOL of the SQL Server version you use.

The text of this error message has changed from SQL Server 2000 to SQL Server 2005.

]]>

Leave a comment

Your email address will not be published.