-1

How do I set the transaction isolation level within in a table value multi function? I know it can be done in a stored procedure.

create function dbo.Test()
RETURNS @TestTable Table (test varchar(1000))
AS 
begin

SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED

I am receiving error below:

Msg 443, Level 16, State 15, Procedure abcde, Line 12
Invalid use of a side-effecting operator 'SET TRANSACTION ISOLATION LEVEL' within a function.
2

You can't set the transaction isolation level inside a function. You can use lock hints on the queries used in the functions instead.

Although you should really avoid using either READ UNCOMMITTED or the nolock lock hint.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy