tsunami

log in
history

DDL Trigger: login

Luke Breuer
2010-04-17 01:34 UTC

code
Note that it's for logon instead of for login.
create trigger DDL_Limit_Connections
on all server with execute as self
for logon
as

if original_login() = 'login_test' and
    (
        select  count(*)
        from    sys.dm_exec_sessions
        where   is_user_process = 1 
            and original_login_name = original_login()
    ) > 3
begin    
    rollback
end