Link to home
Start Free TrialLog in
Avatar of jasonhdz
jasonhdzFlag for United States of America

asked on

SQL Server 2012 Concurrent Sessions

I need help in implementing the following:

Implement logon triggers to restrict users from logging on multiple times.
Avatar of Anthony Perkins
Anthony Perkins
Flag of United States of America image

You do realize that there is a perfectly good example in SQL Server BOL for CREATE TRIGGER (Transact-SQL), right?  Look for Example F
Avatar of jasonhdz

ASKER

No i did not, that is why i asked.  But thanks!  I will check it out!
USE master;
GO
CREATE TRIGGER connection_limit_trigger
ON ALL SERVER WITH EXECUTE AS "JAY-PC\testdba1"
FOR LOGON
AS
BEGIN
IF ORIGINAL_LOGIN()= "JAY-PC\testdba1" AND
    (SELECT COUNT(*) FROM sys.dm_exec_sessions
            WHERE is_user_process = 1 AND
                original_login_name = "JAY-PC\testdba1") > 3
    ROLLBACK;
END;
from the scrip above, i have the following issues:

1.  It looks like the If is looking for a specific user, i need to implement this for every single user login in the db server.
2.  Only Windows Login is implemented.  It does not appear to recognize the Windows User Identificator
ASKER CERTIFIED SOLUTION
Avatar of Anthony Perkins
Anthony Perkins
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial