Sep 11, 2013

Sql script to get the total numbers of login attempt in sql server


Sql query to get the total numbers of log in or connection attempt in sql server since last time sql server had started.

SELECT @@CONNECTIONS AS [Login Attempt]

Sample Output:

Login Attempt
126

To get the log in attempt during the execution of some sql queries:

DECLARE @Connection AS INT
SET @Connection = @@CONNECTIONS

/*
    Sql statements
*/

SELECT @@CONNECTIONS - @Connection AS [Login Attempt]

No comments:

Post a Comment