SQL Server: Troubleshooting Logon Triggers
Logon triggers were introduced in SQL server 2005 SP2. They fire stored procedures in response to a LOGON event. This event is raised when a user session is established with an instance of SQL Server.
Logon triggers can be used to audit and control server sessions, in such usage scenarios as:
- Tracking login activity, you can create a user table to audit user sessions.
- Restricting logins to SQL Server, you can prevent a specific login from establishing a user session.
- limiting the number of sessions for a specific login, you can limit a specific login from establishing more than a specific number of user sessions to the instance.
You can extract useful XML data about Logon events inside Logon by using the EVENTDATA function. I will demonstrate a little later how we can use this function to audit log-ins to a user table.
How do Logon triggers work?
The life cycle of a Logon trigger is simple: (more…)

