问题
In SQL Server 2005, is it possible to automatically set transaction isolation level to, say, read uncommitted an a per-user basis?
(So for instance, if I set such a login option for user Fred, Fred wouldn't have to remember sprinkle his select statements with NOLOCK hints or remember to add in a set transaction isolation level statement to his sql.)
回答1:
if it is for stored procs you could have code like this in the procs
if user_name() in('dbo','username','otherusers','bla')
set transaction isolation level read uncommitted
else
set transaction isolation level read committed
But of course now you have a maintenance problem, all current procs have to be modified
you can also check with suser_sname() but this really becomes a big PITA
you might also be able to use a LOGON Trigger I have not tried and am not sure it will work
来源:https://stackoverflow.com/questions/3685584/in-sql-server-2005-is-it-possible-to-set-transaction-isolation-level-on-a-per-u