Skip to content

Commit 8fdf5f1

Browse files
authored
Merge pull request #3579 from Tisit/dev
sp_Blitz: Fix checks 73 to work with sysadmin permissions
2 parents ae935df + a3d6323 commit 8fdf5f1

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

sp_Blitz.sql

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -334,18 +334,15 @@ AS
334334
END CATCH;
335335
END; /*Need execute on sp_validatelogins*/
336336

337-
IF ISNULL(@SkipGetAlertInfo, 0) != 1 /*If @SkipGetAlertInfo hasn't been set to 1 by the caller*/
338-
BEGIN
339-
BEGIN TRY
340-
/* Try to fill the table for check 73 */
341-
INSERT INTO #AlertInfo
342-
EXEC [master].[dbo].[sp_MSgetalertinfo] @includeaddresses = 0;
343-
344-
SET @SkipGetAlertInfo = 0; /*We can execute sp_MSgetalertinfo*/
345-
END TRY
346-
BEGIN CATCH
347-
SET @SkipGetAlertInfo = 1; /*We have don't have execute rights or sp_MSgetalertinfo throws an error so skip it*/
348-
END CATCH;
337+
IF NOT EXISTS
338+
(
339+
SELECT
340+
1/0
341+
FROM fn_my_permissions(N'[master].[dbo].[sp_MSgetalertinfo]', N'OBJECT') AS fmp
342+
WHERE fmp.permission_name = N'EXECUTE'
343+
)
344+
BEGIN
345+
SET @SkipGetAlertInfo = 1;
349346
END; /*Need execute on sp_MSgetalertinfo*/
350347

351348
IF ISNULL(@SkipModel, 0) != 1 /*If @SkipModel hasn't been set to 1 by the caller*/
@@ -8467,6 +8464,9 @@ IF @ProductVersionMajor >= 10
84678464
BEGIN
84688465

84698466
IF @Debug IN (1, 2) RAISERROR('Running CheckId [%d].', 0, 1, 73) WITH NOWAIT;
8467+
8468+
INSERT INTO #AlertInfo
8469+
EXEC [master].[dbo].[sp_MSgetalertinfo] @includeaddresses = 0;
84708470

84718471
INSERT INTO #BlitzResults
84728472
( CheckID ,

0 commit comments

Comments
 (0)