Skip to content

Commit fb0d8fd

Browse files
committed
#3356 Fix for xp_readerrorlog
1 parent 5e7f4f2 commit fb0d8fd

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
@@ -8621,12 +8621,22 @@ IF @ProductVersionMajor >= 10 AND NOT EXISTS ( SELECT 1
86218621
END
86228622
ELSE
86238623
BEGIN
8624-
INSERT INTO #ErrorLog
8625-
EXEC sys.xp_readerrorlog 0, 1, N'Database Instant File Initialization: enabled';
8624+
BEGIN TRY
8625+
INSERT INTO #ErrorLog
8626+
EXEC sys.xp_readerrorlog 0, 1, N'Database Instant File Initialization: enabled';
8627+
END TRY
8628+
BEGIN CATCH
8629+
IF @Debug IN (1, 2) RAISERROR('No permissions to execute xp_readerrorlog.', 0, 1) WITH NOWAIT;
8630+
END CATCH
86268631
END
86278632

8628-
IF @@ROWCOUNT > 0
8629-
begin
8633+
IF EXISTS
8634+
(
8635+
SELECT 1/0
8636+
FROM #ErrorLog
8637+
WHERE LEFT([Text], 45) = N'Database Instant File Initialization: enabled'
8638+
)
8639+
BEGIN
86308640
INSERT INTO #BlitzResults
86318641
( CheckID ,
86328642
[Priority] ,
@@ -8642,7 +8652,7 @@ IF @ProductVersionMajor >= 10 AND NOT EXISTS ( SELECT 1
86428652
'Instant File Initialization Enabled' AS [Finding] ,
86438653
'https://www.brentozar.com/go/instant' AS [URL] ,
86448654
'The service account has the Perform Volume Maintenance Tasks permission.';
8645-
end
8655+
END;
86468656
else -- if version of sql server has instant_file_initialization_enabled column in dm_server_services, check that too
86478657
-- in the event the error log has been cycled and the startup messages are not in the current error log
86488658
begin

0 commit comments

Comments
 (0)