SET TRANSACTION ISOLATION LEVEL within a function

select, sql, sql-server, sql-server-2008

Solution

You can't. UDFs do not support set operations.

A function is always executing within the context of a transaction (implicitly or explicitly), and you can't change the isolation level of a transaction once it has begun.

Problem

When I want to add the line SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED right after BEGIN clause of my function definition script in SQL SERVER 2008, it says: ``` Invalid use of a side-effecting operator 'SET TRANSACTION ISOLATION LEVEL' within a function ``` How can I achive this functionality within a function definition?

Original source