1

I'm an accidental DBA here,

I am attempting to create a SQL Agent Job that will capture the data for sp_blitzFirst. My goal is to start using the PowerBI dashboard to help show our pain points to management.

When I run the SQL code below, it outputs the data to my tables, but when I run it as a SQL Job, it does nothing. The job succeeds without any errors codes.

EXEC sp_BlitzFirst 
  @OutputDatabaseName = 'DBATOOLS', 
  @OutputSchemaName = 'dbo', 
  @OutputTableName = 'BlitzFirst',
  @OutputTableNameFileStats = 'BlitzFirst_FileStats',
  @OutputTableNamePerfmonStats = 'BlitzFirst_PerfmonStats',
  @OutputTableNameWaitStats = 'BlitzFirst_WaitStats',
  @OutputTableNameBlitzCache = 'BlitzCache',
  @OutputTableNameBlitzWho = 'BlitzWho';

Here is the output from the task:

Message
Executed as user: NT SERVICE\SQLSERVERAGENT. Setting up configuration variables [SQLSTATE 01000] (Message 50000)  
Now starting diagnostic analysis [SQLSTATE 01000] (Message 50000)  
Checking for Read intent databases to exclude [SQLSTATE 01000] (Message 50000)  
Capturing first pass of wait stats, perfmon counters, file stats [SQLSTATE 01000] (Message 50000)  
Beginning investigatory queries [SQLSTATE 01000] (Message 50000)  
Warning: The join order has been enforced because a local join hint is used. [SQLSTATE 01000] (Message 8625)  
Warning: The join order has been enforced because a local join hint is used. [SQLSTATE 01000] (Message 8625)  
Finished running investigatory queries [SQLSTATE 01000] (Message 50000)  Waiting to match @Seconds parameter [SQLSTATE 01000] (Message 50000)  
Capturing second pass of wait stats, perfmon counters, file stats [SQLSTATE 01000] (Message 50000)  
Analyzing changes between first and second passes of DMVs [SQLSTATE 01000] (Message 50000)  
Analysis finished, outputting results [SQLSTATE 01000] (Message 50000).  
The step succeeded.

Any help in the right direction would be appreciated.

Thanks!

  • 1
    Can you post a screenshot of the Agent job config? The way the output looks makes me think the Agent job may not have any parameters configured. – Brent Ozar Nov 7 '19 at 16:26
  • Well that's embarrassing. We aren't using a DB named DBTOOLS in our system, and I didn't use it when running it manually, but forgot to update that in the T-SQL in the task. (I changed the DB name in the post too). So it was trying to write to a non-existent table. It helps to double check your T-SQL. – brndr Nov 7 '19 at 17:07
2

Moving the answer from the comments:

When this happens, start by double-checking the contents of your Agent job, and make sure it exactly matches the command you're running manually.

In this case, the text of the Agent job was calling for a different database name - one that didn't exist - so it was skipping the logging portion. Right now, if you call it with a database name that doesn't exist, it doesn't fail hard. It probably should - if you want to file a Github issue for that at http://FirstResponderKit.org, I can add that.

Not the answer you're looking for? Browse other questions tagged or ask your own question.