Friday, June 29, 2007

Error when creating a SQL function

I have started using functions in SQL 2005 and I really do like them...But (there is always a but) I got this problem....

Msg 443, Level 16, State 1, Procedure UpdateTenders, Line 71
Invalid use of side-effecting or time-dependent operator in 'newid' within a function.
Msg 443, Level 16, State 15, Procedure UpdateTenders, Line 71
Invalid use of side-effecting or time-dependent operator in 'INSERT' within a function.

 

I got it on a rather natty (if that's how you spell natty) function, if I have to say so myself, but I wasn't doing anything strange with Guids, just an insert.

So after a quick google search found nothing, I changed it to be a stored procedure and it worked!! Hurray for simple solutions...

 

If it doesn't work as a sql function; do it as a stored procedure.

No comments: