Skip to content

Commit 7c39562

Browse files
authored
Merge pull request #3361 from Montro1981/SQL-Server-First-Responder-Kit_3356_xp_readerrorlog
#3356 Fix for xp_readerrorlog
2 parents 11a0dd1 + fb0d8fd commit 7c39562

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

sp_Blitz.sql

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8697,12 +8697,22 @@ IF @ProductVersionMajor >= 10 AND NOT EXISTS ( SELECT 1
86978697
END
86988698
ELSE
86998699
BEGIN
8700-
INSERT INTO #ErrorLog
8701-
EXEC sys.xp_readerrorlog 0, 1, N'Database Instant File Initialization: enabled';
8700+
BEGIN TRY
8701+
INSERT INTO #ErrorLog
8702+
EXEC sys.xp_readerrorlog 0, 1, N'Database Instant File Initialization: enabled';
8703+
END TRY
8704+
BEGIN CATCH
8705+
IF @Debug IN (1, 2) RAISERROR('No permissions to execute xp_readerrorlog.', 0, 1) WITH NOWAIT;
8706+
END CATCH
87028707
END
87038708

8704-
IF @@ROWCOUNT > 0
8705-
begin
8709+
IF EXISTS
8710+
(
8711+
SELECT 1/0
8712+
FROM #ErrorLog
8713+
WHERE LEFT([Text], 45) = N'Database Instant File Initialization: enabled'
8714+
)
8715+
BEGIN
87068716
INSERT INTO #BlitzResults
87078717
( CheckID ,
87088718
[Priority] ,
@@ -8718,7 +8728,7 @@ IF @ProductVersionMajor >= 10 AND NOT EXISTS ( SELECT 1
87188728
'Instant File Initialization Enabled' AS [Finding] ,
87198729
'https://www.brentozar.com/go/instant' AS [URL] ,
87208730
'The service account has the Perform Volume Maintenance Tasks permission.';
8721-
end
8731+
END;
87228732
else -- if version of sql server has instant_file_initialization_enabled column in dm_server_services, check that too
87238733
-- in the event the error log has been cycled and the startup messages are not in the current error log
87248734
begin

0 commit comments

Comments
 (0)