Skip to content

Instantly share code, notes, and snippets.

@Otterpohl
Created May 13, 2022 14:44
Show Gist options
  • Save Otterpohl/0c51696868d511b6ed0ecac7addd06d1 to your computer and use it in GitHub Desktop.
Save Otterpohl/0c51696868d511b6ed0ecac7addd06d1 to your computer and use it in GitHub Desktop.
Get sp_blitzwho results as a table
DECLARE @temp_spblitzwho AS TABLE
(
run_date DATETIME2 NULL,
elapsed_time NVARCHAR(30) NULL,
session_id INT NULL,
database_name NVARCHAR(100) NULL,
query_text NVARCHAR(MAX) NULL,
query_plan XML NULL,
live_query_plan XML NULL,
query_cost FLOAT NULL,
status NVARCHAR(30) NULL, -- int
wait_info NVARCHAR(512) NULL,
top_session_waits NVARCHAR(512) NULL,
blocking_session_id INT NULL,
open_transaction_count INT NULL,
is_implicit_transaction BIT NULL,
nt_domain NVARCHAR(30) NULL,
host_name NVARCHAR(30) NULL,
login_name NVARCHAR(100) NULL,
nt_user_name NVARCHAR(100) NULL,
program_name NVARCHAR(200) NULL
);
INSERT INTO @temp_spblitzwho
EXEC dbo.sp_BlitzWho;
SELECT run_date,
elapsed_time,
session_id,
database_name,
query_text,
query_plan,
live_query_plan,
query_cost,
status,
wait_info,
top_session_waits,
blocking_session_id,
open_transaction_count,
is_implicit_transaction,
nt_domain,
host_name,
login_name,
nt_user_name,
program_name
FROM @temp_spblitzwho
WHERE session_id > 50
AND session_id <> @@SPID;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment