Comments
1 comment
-
It's trying to read the error log from SQL Server to find out how many login failures there were. The run time of the query depends on how long the error log is and how quick the network is. You can try changing the SQL Server setting that controls how often SQL Server recycles its' error log so there is less to be read.
Add comment
Please sign in to leave a comment.
DECLARE @endtime DATETIME; SET @endtime = GETDATE();
DECLARE @starttime DATETIME; SET @starttime = DATEADD(hh, -1, @endtime);
IF OBJECT_ID('tempdb..#LogEntries') IS NOT NULL DROP TABLE #LogEntries;
CREATE TABLE #LogEntries ( LogDate DATETIME , ProcessInfo VARCHAR(1000) , LogMessage TEXT ); INSERT INTO #LogEntries
EXEC sys.xp_readerrorlog 0, 1, N'Login', N'failed', @starttime, @endtime;
SELECT COUNT(*) FROM #LogEntries; DROP TABLE #LogEntries;