Home Forums SQL Server 2014 Development - SQL Server 2014 How to call procedure from function. Getting error Invalid use of side-effecting or time-dependent operator in 'INSERT EXEC' within a function. RE: How to call procedure from function. Getting error Invalid use of side-effecting or time-dependent operator in 'INSERT EXEC' within a function.

  • INSERT EXEC is not the best method by itself.

    I would try to extract the code from your SP and wrap it in new function, then change the SP to call this function, and in the function you are working on you could just call that other function.

    This way you wouldn't duplicate the code, the applications, calling your SP wouldn't be affected and you wouldn't have to use INAERT EXEC.

    Of course this method works only if your SP doesn't use dynamic SQL and other things, not allowed to use within a function 🙂