T-sql – How to get Brent Ozar’s sp_BlitzIndex to run on Azure

azure-sql-databaseazure-sql-database-v11sp-blitzindext-sql

I downloaded the SQL Server First Aid Kit from Brent Ozar's website. When I tried to run the sp_BlitzIndex script against my master database via Microsoft Sql Server Management Studio while logged in as the Azure database server level admin and I got the following error:

Msg 262, Level 14, State 18, Procedure sp_BlitzIndex, Line 18 CREATE
PROCEDURE permission denied in database 'master'.

I successfully created the procedure on the database instance I wanted to test. When I executed the procedure I got an error stating:

Msg 50000, Level 16, State 1, Line 1265 Invalid object name
'mydatabase.sys.partitions'.

Next I tried to be clever and run the stored procedure code directly against the master database without creating the stored procedure and got the following error:

Msg 50000, Level 15, State 1, Line 1267 Reference to database and/or
server name in 'mydatabase.sys.indexes' is not supported in this
version of SQL Server.

I don't feel confident enough to start toying with the inner workings of ~2700 lines of index heuristic logic. Is there a quick, and easy way to get this stored procedure to work nicely on Azure SQL Database or should I look elsewhere for an index analyzing tool/stored procedure?

Best Answer

Kendra here (the author of sp_BlitzIndex)

First, thanks for being interested in the procedure and trying it out.

Azure doesn't expose all the dynamic management views that we get in the boxed product. I do actually reference sys.dm_db_partition_stats, but there's other info I need to get from sys.partitions for other users. (Is it using compression? What type?)

I haven't had time to write an test an Azure specific version, just because I haven't had a lot of demand for it. But your question does tell me there's more interest than I knew of -- so there's that!

I will at minimum look at implementing some error handling so it lets you know in a graceful way though. (This is a bit of a moving target, because Azure has been expanding the features that are available to users as well.)