The error message
Invalid use of side-effecting or time-dependent operator in ‘INSERT’ within a function
is encountered when an attempt is made to apply a DML statement through a function (user defined function)in your SQL Server database. To avoid the error make sure that your function is not performing any DML operation and also it is not calling any stored procedure to do so. A alternate approach is that if you don’t have to use function within query, you can write it as stored procedure.