In SQL Server 2005, is it possible to set transaction isolation level on a per-user basis?

筅森魡賤 提交于 2021-02-04 18:30:47

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!