Mike,
The UPDATE, INSERT, and DELETE statements modifying table variables that are local to the function are only allowed in a UDF. There's a trick to get around this using OPENQUERY() function but it is very limited because OPENQUERY() function doesn't accept local variable as the second parameter, only string literals. Anyway, take a look at
Re: Bug or Behaviour ? Message #
814101. The other option could be to convert it into stored procedure with output parameter.
>We have an inventory function that accepts 3 parameters and returns one value. This function is used through out the program by several different stored procedures. We have a need to log some of these calls to this function. I tried using an insert command from within this function and I get this error…
>
>“Only functions and extended stored procedures can be executed from within a function.”
>
>Can you and how do you insert from within a function?
--sb--