@@ -19,6 +19,7 @@ ALTER PROCEDURE [dbo].[sp_BlitzFirst]
1919 @OutputTableNameWaitStats NVARCHAR (256 ) = NULL ,
2020 @OutputTableNameBlitzCache NVARCHAR (256 ) = NULL ,
2121 @OutputTableNameBlitzWho NVARCHAR (256 ) = NULL ,
22+ @OutputResultSets NVARCHAR (500 ) = N ' BlitzWho_Start|Findings|FileStats|PerfmonStats|WaitStats|BlitzCache|BlitzWho_End' ,
2223 @OutputTableRetentionDays TINYINT = 7 ,
2324 @OutputXMLasNVARCHAR TINYINT = 0 ,
2425 @FilterPlansByDatabase VARCHAR (MAX ) = NULL ,
@@ -262,7 +263,7 @@ END; /* IF @AsOf IS NOT NULL AND @OutputDatabaseName IS NOT NULL AND @OutputSche
262263ELSE IF @LogMessage IS NULL /* IF @OutputType = 'SCHEMA' */
263264BEGIN
264265 /* What's running right now? This is the first and last result set. */
265- IF @SinceStartup = 0 AND @Seconds > 0 AND @ExpertMode = 1 AND @OutputType <> ' NONE'
266+ IF @SinceStartup = 0 AND @Seconds > 0 AND @ExpertMode = 1 AND @OutputType <> ' NONE' AND @OutputResultSets LIKE N ' %BlitzWho_Start%'
266267 BEGIN
267268 IF OBJECT_ID (' master.dbo.sp_BlitzWho' ) IS NULL AND OBJECT_ID (' dbo.sp_BlitzWho' ) IS NULL
268269 BEGIN
@@ -4508,7 +4509,7 @@ If one of them is a lead blocker, consider killing that query.'' AS HowToStopit,
45084509 FROM #BlitzFirstResults;
45094510 END ;
45104511 ELSE
4511- IF @OutputType = ' Opserver1' AND @SinceStartup = 0
4512+ IF @OutputType = ' Opserver1' AND @SinceStartup = 0 AND @OutputResultSets LIKE N ' %Findings%'
45124513 BEGIN
45134514
45144515 SELECT r.[Priority] ,
@@ -4565,7 +4566,7 @@ If one of them is a lead blocker, consider killing that query.'' AS HowToStopit,
45654566 r .Finding ,
45664567 r .ID ;
45674568 END ;
4568- ELSE IF @OutputType IN ( ' CSV' , ' RSV' ) AND @SinceStartup = 0
4569+ ELSE IF @OutputType IN ( ' CSV' , ' RSV' ) AND @SinceStartup = 0 AND @OutputResultSets LIKE N ' %Findings%'
45694570 BEGIN
45704571
45714572 SELECT Result = CAST ([Priority] AS NVARCHAR (100 ))
@@ -4586,7 +4587,7 @@ If one of them is a lead blocker, consider killing that query.'' AS HowToStopit,
45864587 Finding,
45874588 Details;
45884589 END ;
4589- ELSE IF @OutputType = ' Top10'
4590+ ELSE IF @OutputType = ' Top10' AND @OutputResultSets LIKE N ' %WaitStats%'
45904591 BEGIN
45914592 /* Measure waits in hours */
45924593 ;WITH max_batch AS (
@@ -4623,7 +4624,7 @@ If one of them is a lead blocker, consider killing that query.'' AS HowToStopit,
46234624 AND wd2 .wait_time_ms - wd1 .wait_time_ms > 0
46244625 ORDER BY [Wait Time (Seconds)] DESC ;
46254626 END ;
4626- ELSE IF @ExpertMode = 0 AND @OutputType <> ' NONE' AND @OutputXMLasNVARCHAR = 0 AND @SinceStartup = 0
4627+ ELSE IF @ExpertMode = 0 AND @OutputType <> ' NONE' AND @OutputXMLasNVARCHAR = 0 AND @SinceStartup = 0 AND @OutputResultSets LIKE N ' %Findings%'
46274628 BEGIN
46284629 SELECT [Priority] ,
46294630 [FindingsGroup] ,
@@ -4645,7 +4646,7 @@ If one of them is a lead blocker, consider killing that query.'' AS HowToStopit,
46454646 ID,
46464647 CAST (Details AS NVARCHAR (4000 ));
46474648 END ;
4648- ELSE IF @OutputType <> ' NONE' AND @OutputXMLasNVARCHAR = 1 AND @SinceStartup = 0
4649+ ELSE IF @OutputType <> ' NONE' AND @OutputXMLasNVARCHAR = 1 AND @SinceStartup = 0 AND @OutputResultSets LIKE N ' %Findings%'
46494650 BEGIN
46504651 SELECT [Priority] ,
46514652 [FindingsGroup] ,
@@ -4667,7 +4668,7 @@ If one of them is a lead blocker, consider killing that query.'' AS HowToStopit,
46674668 ID,
46684669 CAST (Details AS NVARCHAR (4000 ));
46694670 END ;
4670- ELSE IF @ExpertMode = 1 AND @OutputType <> ' NONE'
4671+ ELSE IF @ExpertMode = 1 AND @OutputType <> ' NONE' AND @OutputResultSets LIKE N ' %Findings%'
46714672 BEGIN
46724673 IF @SinceStartup = 0
46734674 SELECT r.[Priority] ,
@@ -4729,7 +4730,7 @@ If one of them is a lead blocker, consider killing that query.'' AS HowToStopit,
47294730 -- -----------------------
47304731 -- What happened: #WaitStats
47314732 -- -----------------------
4732- IF @Seconds = 0
4733+ IF @Seconds = 0 AND @OutputResultSets LIKE N ' %WaitStats%'
47334734 BEGIN
47344735 /* Measure waits in hours */
47354736 ;WITH max_batch AS (
@@ -4773,7 +4774,7 @@ If one of them is a lead blocker, consider killing that query.'' AS HowToStopit,
47734774 AND wd2 .wait_time_ms - wd1 .wait_time_ms > 0
47744775 ORDER BY [Wait Time (Seconds)] DESC ;
47754776 END ;
4776- ELSE
4777+ ELSE IF @OutputResultSets LIKE N ' %WaitStats%'
47774778 BEGIN
47784779 /* Measure waits in seconds */
47794780 ;WITH max_batch AS (
@@ -4821,6 +4822,7 @@ If one of them is a lead blocker, consider killing that query.'' AS HowToStopit,
48214822 -- -----------------------
48224823 -- What happened: #FileStats
48234824 -- -----------------------
4825+ IF @OutputResultSets LIKE N ' %FileStats%'
48244826 WITH readstats AS (
48254827 SELECT ' PHYSICAL READS' AS Pattern,
48264828 ROW_NUMBER () OVER (ORDER BY wd2 .avg_stall_read_ms DESC ) AS StallRank,
@@ -4879,7 +4881,8 @@ If one of them is a lead blocker, consider killing that query.'' AS HowToStopit,
48794881 -- What happened: #PerfmonStats
48804882 -- -----------------------
48814883
4882- SELECT ' PERFMON' AS Pattern, pLast.[object_name], pLast .counter_name , pLast .instance_name ,
4884+ IF @OutputResultSets LIKE N ' %PerfmonStats%'
4885+ SELECT ' PERFMON' AS Pattern, pLast.[object_name], pLast .counter_name , pLast .instance_name ,
48834886 pFirst .SampleTime AS FirstSampleTime, pFirst .cntr_value AS FirstSampleValue,
48844887 pLast .SampleTime AS LastSampleTime, pLast .cntr_value AS LastSampleValue,
48854888 pLast .cntr_value - pFirst .cntr_value AS ValueDelta,
@@ -4894,7 +4897,7 @@ If one of them is a lead blocker, consider killing that query.'' AS HowToStopit,
48944897 -- -----------------------
48954898 -- What happened: #QueryStats
48964899 -- -----------------------
4897- IF @CheckProcedureCache = 1
4900+ IF @CheckProcedureCache = 1 AND @OutputResultSets LIKE N ' %BlitzCache%'
48984901 BEGIN
48994902
49004903 SELECT qsNow.* , qsFirst.*
@@ -4911,7 +4914,7 @@ If one of them is a lead blocker, consider killing that query.'' AS HowToStopit,
49114914 DROP TABLE #BlitzFirstResults;
49124915
49134916 /* What's running right now? This is the first and last result set. */
4914- IF @SinceStartup = 0 AND @Seconds > 0 AND @ExpertMode = 1 AND @OutputType <> ' NONE'
4917+ IF @SinceStartup = 0 AND @Seconds > 0 AND @ExpertMode = 1 AND @OutputType <> ' NONE' AND @OutputResultSets LIKE N ' %BlitzWho_End%'
49154918 BEGIN
49164919 IF OBJECT_ID (' master.dbo.sp_BlitzWho' ) IS NULL AND OBJECT_ID (' dbo.sp_BlitzWho' ) IS NULL
49174920 BEGIN
0 commit comments