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.




Related Articles :

  • No Related Articles Found

No comments yet... Be the first to leave a reply!

Software Reviews | Book Reviews | FAQs | Tips | Articles | Performance Tuning | Audit | BI | Clustering | Developer | Reporting | DBA | ASP.NET Ado | Views tips | | Developer FAQs | Replication Tips | OS Tips | Misc Tips | Index Tuning Tips | Hints Tips | High Availability Tips | Hardware Tips | ETL Tips | Components Tips | Configuration Tips | App Dev Tips | OLAP Tips | Admin Tips | Software Reviews | Error | Clustering FAQs | Performance Tuning FAQs | DBA FAQs |