From ac6531e154ad324824d92c3e8deb18729d670772 Mon Sep 17 00:00:00 2001 From: Brent Ozar Date: Wed, 22 May 2024 15:27:55 -0700 Subject: [PATCH] #3522 sp_BlitzIndex permissions Fixing error if they can't query sql_expression_dependencies. Closes #3522. --- Install-All-Scripts.sql | 9 +++++++-- Install-Azure.sql | 9 +++++++-- sp_BlitzIndex.sql | 9 +++++++-- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/Install-All-Scripts.sql b/Install-All-Scripts.sql index 377f9fa5..5001508d 100644 --- a/Install-All-Scripts.sql +++ b/Install-All-Scripts.sql @@ -22809,8 +22809,13 @@ OPTION (RECOMPILE);'; AND ic.object_id = sed.referenced_id ) OPTION(RECOMPILE);' - INSERT #FilteredIndexes ( database_id, database_name, schema_name, table_name, index_name, column_name ) - EXEC sp_executesql @dsql, @params = N'@i_DatabaseName NVARCHAR(128)', @i_DatabaseName = @DatabaseName; + BEGIN TRY + INSERT #FilteredIndexes ( database_id, database_name, schema_name, table_name, index_name, column_name ) + EXEC sp_executesql @dsql, @params = N'@i_DatabaseName NVARCHAR(128)', @i_DatabaseName = @DatabaseName; + END TRY + BEGIN CATCH + RAISERROR (N'Skipping #FilteredIndexes population due to error, typically low permissions.', 0,1) WITH NOWAIT; + END CATCH END; END; diff --git a/Install-Azure.sql b/Install-Azure.sql index 1e59498f..acc04d6b 100644 --- a/Install-Azure.sql +++ b/Install-Azure.sql @@ -16008,8 +16008,13 @@ OPTION (RECOMPILE);'; AND ic.object_id = sed.referenced_id ) OPTION(RECOMPILE);' - INSERT #FilteredIndexes ( database_id, database_name, schema_name, table_name, index_name, column_name ) - EXEC sp_executesql @dsql, @params = N'@i_DatabaseName NVARCHAR(128)', @i_DatabaseName = @DatabaseName; + BEGIN TRY + INSERT #FilteredIndexes ( database_id, database_name, schema_name, table_name, index_name, column_name ) + EXEC sp_executesql @dsql, @params = N'@i_DatabaseName NVARCHAR(128)', @i_DatabaseName = @DatabaseName; + END TRY + BEGIN CATCH + RAISERROR (N'Skipping #FilteredIndexes population due to error, typically low permissions.', 0,1) WITH NOWAIT; + END CATCH END; END; diff --git a/sp_BlitzIndex.sql b/sp_BlitzIndex.sql index 6a1fc818..16b130ff 100644 --- a/sp_BlitzIndex.sql +++ b/sp_BlitzIndex.sql @@ -2502,8 +2502,13 @@ OPTION (RECOMPILE);'; AND ic.object_id = sed.referenced_id ) OPTION(RECOMPILE);' - INSERT #FilteredIndexes ( database_id, database_name, schema_name, table_name, index_name, column_name ) - EXEC sp_executesql @dsql, @params = N'@i_DatabaseName NVARCHAR(128)', @i_DatabaseName = @DatabaseName; + BEGIN TRY + INSERT #FilteredIndexes ( database_id, database_name, schema_name, table_name, index_name, column_name ) + EXEC sp_executesql @dsql, @params = N'@i_DatabaseName NVARCHAR(128)', @i_DatabaseName = @DatabaseName; + END TRY + BEGIN CATCH + RAISERROR (N'Skipping #FilteredIndexes population due to error, typically low permissions.', 0,1) WITH NOWAIT; + END CATCH END; END;