Skip to content

Commit 60b3141

Browse files
BrentOzarclaude
andcommitted
sp_BlitzLock: return helpful message on Azure SQL DB instead of error
Fixes #3892 - Azure SQL DB does not have the system_health XE session, so sp_BlitzLock would raise a severity-11 error. Now returns a severity-0 informational message with instructions for creating a database-scoped deadlock XE session or using a table target. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 3fafcb0 commit 60b3141

1 file changed

Lines changed: 25 additions & 2 deletions

File tree

sp_BlitzLock.sql

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -570,8 +570,31 @@ BEGIN
570570
AND dxs.create_time IS NOT NULL
571571
)
572572
BEGIN
573-
RAISERROR('A session with the name %s does not exist or is not currently active.', 11, 1, @EventSessionName) WITH NOWAIT;
574-
RETURN;
573+
IF @EventSessionName = N'system_health'
574+
BEGIN
575+
RAISERROR('
576+
The system_health extended events session is not available in Azure SQL DB.
577+
578+
To use sp_BlitzLock in Azure SQL DB, you have two options:
579+
580+
1. Create a database-scoped deadlock XE session, e.g.:
581+
582+
CREATE EVENT SESSION [deadlocks] ON DATABASE
583+
ADD EVENT sqlserver.xml_deadlock_report
584+
ADD TARGET package0.ring_buffer;
585+
ALTER EVENT SESSION [deadlocks] ON DATABASE STATE = START;
586+
587+
Then call: EXEC sp_BlitzLock @EventSessionName = N''deadlocks'', @TargetSessionType = N''ring_buffer'';
588+
589+
2. Log deadlock XML to a table and use the @TargetTableName parameter.
590+
', 0, 1) WITH NOWAIT;
591+
RETURN;
592+
END;
593+
ELSE
594+
BEGIN
595+
RAISERROR('A session with the name %s does not exist or is not currently active.', 11, 1, @EventSessionName) WITH NOWAIT;
596+
RETURN;
597+
END;
575598
END;
576599
END;
577600

0 commit comments

Comments
 (0)