By David Wiseman (Administrator)published 13 Jul 2009, modified 03 Apr 2012
My Rating:
Not Rated

DBA Daily Checks Email Report


DBAs typically create a number of alerts to inform them of potential problems with their database servers.  In addition to these alerts, it's also important to proactively monitor your database servers by running a series of daily checks.  The exact checks performed will vary from organization to organization, but some common ones include:

  • Check backups
  • Check SQL Server agent jobs
  • Check disk space
  • Check free space in database files
  • Check SQL Server error log
  • Check Windows event logs

Your daily checks might not be limited to those listed above and you might also have more comprehensive checks on a weekly/monthly/quarterly basis. 

One of the problems with daily checks is that the information you need to complete your checks isn't available in a single location and potential problems are not always highlighted.  To improve this process I created a stored procedure to send a HTML email report for the SQL Server instance, which is automated via the SQL Server Agent.  If you haven't already found a good method of performing daily checks, the DBAChecks stored procedure in this article might give you a good starting point.

Report Sample

The image below is a sample report that was generated from a test instance of SQL Server. 

 DBA Checks HTML Report Sample


  • SQL Server 2005 (SP3)
    There seems to be a bug in earlier builds related to attachments in email messages.  You might get an error similar to this one:
    Exception happened when running extended stored procedure 'xp_sysmail_format_query' in the library 'xpstar90.dll'. SQL Server is terminating process 62. Exception type: Win32 exception; Exception code: 0xc0000005.
    You can fix this by upgrading to the latest service pack or removing the code that adds the error log attachment to the email.  Restarting the SQL Server Agent can also provide a temporary fix for this issue, but the problem is likely to re-occur.
  • SQL Server 2008
  • SQL Server 2008 R2

Installation Instructions

  • Create a database for DBA related tasks if one doesn't already exist.
  • Install SQLIO_fnGetDrives() CLR function.  See here.
  • Install DBA Checks stored procedures.  Download.
  • Make sure you have configured database mail on the SQL Server instance.
  • Create a SQL Server Agent Job to run the dbo.DBAChecks stored procedure.

Version History

Date Version Notes
03-Apr-2012Version 1.2 BETAFix to DBAChecks_JobStats stored procedure.  Added CDATA section.
14-Dec-2010 Version 1.1 BETA Fixed datetime conversion bug in DBAChecks_JobStats procedure.
13-Jul-2009 Version 1.0 BETA Beta release

Running the report

The DBA Checks report is run by executing the dbo.DBAChecks stored procedure.  This stored procedure takes a number of parameters, but only one is required:

exec dbo.DBAChecks @recipients=''

The code below shows a call to the DBAChecks stored procedure with all parameters specified:

EXEC dbo.DBAChecks @AgentJobsNumDays=3,
@UptimeCritical=1440 ,

A full explanation of these parameters is available here:

 @AgentJobsNumDays The number of days SQL SQL Server jobs are reported over.
 @FileStatsIncludedDatabases A list of databases (comma-separated) to display file stats for.  Default value is NULL (All databases).
 @FileStatsExcludedDatabases A list of databases (comma-separated) that are excluded from database file stats.  Default values is NULL (No excluded databases)
 @FileStatsPctUsedWarning If the percent used space in the database file is larger than this value (but less than critical threshold) it will be highlighted in yellow.
 @FileStatsPctUsedCritical If the percent used space in the database file is larger than this value it will be highlighted in red.
 @DiffWarningThresholdDays Highlights differential backups that have not been completed for over "X" number of days
 @FullWarningThresholdDays Highlights full backups that have not been completed for over "X" number of days
 @TranWarningThresholdHours Highlights transaction log backups that have not been completed for over "X" number of hours.
 @FreeDiskSpacePercentWarningThreshold Used to highlight disk drives with low disk space in yellow, where the free disk space percent is less than the value specified.
 @FreeDiskSpacePercentCriticalThreshold Used to highlight disk drives with low disk space in red, where the free disk space percent is less than the value specified.
 @UptimeCritical The uptime in minutes threshold that causes the uptime to be highlighted in red.
 @UptimeWarning The uptime in minutes threshold that causes the uptime to be highlighted in yellow.
 @ErrorLogDays The number of days worth of events included in the attached error log html file.
 @Recipients The email addresses where the report will be sent.
 @MailProfile The mail profile used to send the email.  NULL = default profile.

Database Code

Name Info
dbo.DBAChecks This is the stored procedure you run to generate the email report. The stored procedure collates the information from the other stored procedures into a single email report.   The parameters are described in the previous section. 
dbo.DBAChecks_Backups Produces HTML for the "Backups" section of the report.
dbo.DBAChecks_DBFiles Produces HTML for the "Database Files" section of the report. 
dbo.DBAChecks_DiskDrives Produces HTML for the "Disk Drives" section of the report.
dbo.DBAChecks_ErrorLog Produces HTML for the "ErrorLog.htm" report attachment.  Review and ammend the filter applied to the error log as appropriate.
dbo.DBAChecks_FailedAgentJobs Produces HTML for the "Failed Jobs" section of the report.
dbo.DBAChecks_JobStats Produces HTML for the "Agent Job Stats" section of the report
dbo.SQLIO_fnGetDrives() This CLR function is used by the dbo.DBAChecks_DiskDrives stored procedure to produce the report on disk drives and their available free space.  This function can be obtained here.


Daily checks are an important part of any DBA's routine, giving you confidence that your SQL instances are running problem free and allowing you to take corrective actions when required.  Alerts are also important, but these should be used to compliment daily checks, rather than to replace them.  If you rely on by exception reporting only, your servers will be at risk if something happens to the alert process. 

I'm sure there are a wide variety of methods people currently use to perform their daily checks. The process you use is not important as long as it enables you to effectively monitor your SQL Server instances. If you've already got a routine that works for you - great!  If not, hopefully this article will provide you with a better solution.

  Post Comment
Order By:  
User Comments
Posted On: 11/11/2009 1:30:38 AM

Thanks for this - is there a way to produce the report for remote SQL servers so you can run them centrally from one server?

David Wiseman (Administrator)
United Kingdom
Posted On: 12/14/2010 12:10:03 PM

The code would need to be installed on each server. The stored procedure could be executed remotely from a central server, but it's probably eaiser to create a separate job on each server.

Posted On: 6/29/2012 4:41:00 AM

I haapen to have one instance with collation Polish_CS_AS_KS where the DBAChecks_Backups procedure won't install because I get "Must declare the scalar variable @TranWarningThresholdHours" (and some others) when parsing the script. I already tried creating a separate utility database with normal collation and run the script against it, but did not help (?)
How can I install the procedure without having to change the instance collation?

Posted On: 7/2/2012 8:32:51 AM

I'll answer my own question: after minor corrections of the names (upper/lower case) of some of the variables everything went through just fine. The variables that needed name-consistency adjustments were: @server, @TranWarningThresholdHours, @UptimeWarning, @DiffWarningThresholdDays and @nextrun

Posted On: 6/29/2015 5:20:51 AM

First of all i would like to thank you for this very useful guide!
i have only one question for you:
In case i want to produce the html report locally and export it to my server and not send it via email,what are the changes that i have to make for this?

Thank you in advance

Posted On: 9/28/2016 4:30:36 AM

Failed to initialize sqlcmd library with error number -2147024809. [SQLSTATE 42000] (Error 22050). The step failed. - any update/fix
for the above issue

Posted On: 9/28/2016 6:31:46 AM

Error collecting backup info? help please..

Posted On: 9/28/2016 7:47:13 AM

Error collecting backup info? help please..

Posted On: 12/10/2016 10:31:29 AM

Well Done - I've just deployed this against our small SQL estate and a good solution for us.

Posted On: 3/1/2017 12:10:17 PM

Hi, for all with problem:

Cannot resolve the collation conflict between "SQL_Latin1_General_CP1_CI_AS" and "Latin1_General_CI_AS" in the equal to operation.

The column fullrec.database_name and in line 37, 38 and 80

put fullrec.database_name COLLATE DATABASE_DEFAULT

Ex: fullrec.database_name COLLATE DATABASE_DEFAULT in (select name from master..sysdatabases )
and fullrec.database_name COLLATE DATABASE_DEFAULT <> 'tempdb'

And select * from msdb..backupset where COLLATE DATABASE_DEFAULT = database_name and server_name = @server

Posted On: 3/21/2017 7:24:09 AM

I'am getting the following error message.

Failed to initialize sqlcmd library with error number -2147024809

Please advise. Thanks.

Posted On: 3/29/2017 12:17:23 PM [Edited 3/29/2017 12:19:08 PM]

For those with error:

Failed to initialize sqlcmd library with error number -2147024809

on MSSQL 2014, this fixed it for me:
Modify the following in the stored procedure DBAChecks:

(all the way on the bottom)
EXEC msdb.dbo.sp_send_dbmail
@attach_query_result_as_file = 1,
@query_attachment_filename = 'ErrorLog.htm',
@query_result_header = 1, -- this needs to be 1
@query_no_truncate = 1,
@recipients =@Recipients,
@body = @HTML,
@body_format ='HTML',
@subject = @subject,
@profile_name = @MailProfile

More details on:

Posted On: 7/13/2017 10:33:53 PM

Hi All,

Can you please help me to add offline databases status to this code...


Posted On: 9/12/2017 7:52:16 PM

You've got lunch and then study-hall, right? That's two hours. Plentyof time to run down this clue and Ugg Pas Cher Femme get back before asics sko anyone misses us. chaussures nike pas cher I'llget the whole team out.

Harajuku Fun Madness is the best Cheap True Religion Jeans game ever made. I know I alreadysaid that, but it bears repeating. It's an ARG, an Alternate Nike Shoes Sale Store Reality Game,and the story Cheap Michael Kors Handbags goes that Yeezy Boost Sale Online a gang of Japanese fashion-teens discovered a mi-raculous healing gem at the temple in Cheap True Religion Jeans Harajuku, which is Christian Louboutin Shoes Outlet basicallywhere cool Japanese teenagers invented every major subculture for Nike Air Jordan 11 thepast ten years. They're being Timberland Outlet hunted by evil monks, the Yakuza Cheap Nike Air Huarache (AKAthe Japanese mafia), aliens, tax-inspectors, parents, and a rogue Uggs For Cheap artificialintelligence. They Billige Nike Sko slip Air Jordan Retro Sale the players coded messages that we have to de-code and use Moncler Jackets Discount Marketplace to track down clues nike air jordan pas cher that lead Adidas Yeezy Cheap to more coded messages andmore Hyperdunk 2014 clues.

Imagine Nike Kyrie the best Michael Kors Handbags Discount afternoon you've ever spent prowling the Nike Air 90 streets Coach Bags On Sale of acity, checking out all the Nike Air Max Cheap weird people, funny hand-bills, street-maniacs,and funky shops. Now Cheap Michael Kors Tote Bag add Air Max Sneakers a scavenger hunt to that, It was hard to UGGS Outlet stay cool on the bus. We new yeezy shoes were all a little drunk, andlooking Cheap Toms Shoes Outlet at our faces under the bright bus lights was kind Mens Nike Air Max of hilarious. Wegot pretty loud and the driver used his intercom to tell us to günstige nike schuhe keep pandora outlet store itdown twice, then told us to shut up right now or Coach Outlet Store Online he'd call the cops.

That set us Canada Goose Online Store to giggling again and we Nike Air Shoes disembarked Nike Huarache Womens Cheap in a mass before hedid Cheap Nike Huarache call the cops. We were in North Pandora Store Sale Beach now, and there were Nike Air Damen lots ofbuses, taxis, the BART at Market Street, neon-lit clubs coach factory outlet online and cafes The official UGG to pullapart our Stone Island Outlet grouping, so we drifted away.

I got home and fired up my Xbox and started typing ugg factory outlet in keys from myphone's screen. It Adidas Superstar Sale Online was dull, Nike Air Max Goedkoop hypnotic work. I was a little drunk, and itlulled me Adidas Neo Discount Sale into a half-sleep.Don't you even read Xnet? It's all over Scarpe Air Max the place. You ever hear of theSpeedwhores?

I nearly TOMS For Sale choked. That was Jordan Store Trudy Ugg boots Sale Doo's band — as in Trudy Doo, thewoman who Yeezy Shoes Discount Marketplace had TOMS OUTLET paid me and Jolu to update the indienet code.


Yeah I've heard of them>

They're putting on a nfl store huge Uggs Pas Cher Soldes show Chaussure Nike Air Max Pas Cher and they've got nike sneakers like fifty bands signedto play Bottes Ugg Femme Pas Cher the bill, Abercrombie and fitch store going to set Nike Roshe Run Sale up on the tennis courts and bring out theirown amp trucks and Chaussure Nike Pas Cher rock out Jordan Shoes Air all nightI felt Nike Pas Cher Femme like I'd been living Soccer Boots Outlet nike under a rock. How had I missed that? Therewas an anarchist bookstore on Valencia that Ray Ban Sunglasses Online I sometimes passed on theway to school that Doudoune Moncler Femme Pas Cher had a poster of an old revolutionary named EmmaGoldman adidas store with the caption "If canada goose jacket outlet I can't dance, I don't want new jordan releases to be UGG BOOTS FOR WOMEN a part ofyour revolution." I'd been new pandora charms spending all Nike Shox Cheap my energies Moncler Outlet on Air max dam figuring Jordan Shoes For Cheap out howto use the Kobe Shoes Nike Xnet to Nike Factory Outlet organize dedicated fighters so they could jam newest lebron shoes the Pandora Outlet DHS,but this was Michael Kors Outlet so nike schuhe günstig much cooler. A moncler jacket sale big concert — I Discount Air Max had no idea how to doone of those, but I was Yeezy Men glad someone zapatos de futbol nike did.

And cheap uggs now that I thought Descuentos Nike of it, I was damned Nike Shoes Online proud Michael Kors Clearance that they were us-ing Nike Soccer Cleats Boots the Xnet to do Nike Free Run 5.0 Womens it.

The North Face Outlet next day I was a Adidas Soccer Cleats Cheap zombie. Ange and I had chatted Nike Factory Store — flirted — until4AM. Lucky for Ugg Outlet Online Store me, toms shoes outlet it was a Saturday and I was able to Canada Goose Outlet sleep in, Negozi Pandora but147between the hangover and Official NHL Jerseys the Moncler Sale sleep-dep, I could barely put Cheap Michael Kors twothoughts together.

By lunchtime, I managed to get up Nike Store and get my ass out onto the streets.

I staggered Official Toms Shoes Outlet down toward the Turk's prada outlet to pandora jewelry store buy my coffee — these days, if Iwas alone, Original Ugg Boots I always Discount TOMS bought my coffee there, like Boost Yeezy Sale On Line the Chaussure Air Max Turk Cheap Louboutin Heels and I were partof Louboutin Wedding Shoes a secret club.

On the way, I passed a lot of fresh graffiti. I liked Mission graffiti; a lotof the times, it came scarpe nike in huge, luscious murals, or sarcastic art-studentstencils. I liked that the Mission's taggers kept Nike Air Huarache For Sale right on going, under thenose of the DHS. Cheap Toms Outlet Store Another chaussure basket homme kind Nike Roshe Run of Xnet, I supposed Air Max Kopen — they must converse store have allkinds of ways of knowing what was going on, where to get paint, Adidas Superstar whatcameras Pandora Official Website worked. Some Air Max Femme of the cameras had nike shoes been spray-painted over, Inoticed.

Maybe they Canada Goose Outlet used Xnet!

Painted in ten-foot-high letters on the Jordan Sneakers For Sale side of an auto-yard's Canada Goose Womens Coats fence Moncler Outlet Online werethe drippy words: DON'T TRUST ANYONE Canada goose dam OVER 25.

I Ugg Pas Cher En France stopped. Adidas Originals Stan Smith Had botas de futbol someone left my "party" last night and come here witha can of paint? Zapatillas Air Max A lot of Nike Shox discount Sale those fitflops sale uk people lived in the Air Max 90 neighborhood.

I got my ?????? ????? coffee Boutique Ugg and had a nike tn pas cher little Zapatillas Nike Air Max Baratas wander around town. Air max levne I kept longchamp bags on sale thinking Ishould be calling someone, seeing if they Toms Outlet Online wanted to get a ugg clearance movie Hugo Boss Sale orsomething. That's how it used Air Max Pas Cher to be Christian Louboutin Heels on a lazy Saturday like this. But whowas I going to call? Pandora Store Van Nike Air Pas Cher wasn't talking to Nike Outlet Store me, Discount Christian Louboutin Shoes I didn't think I was Nike Outlet readyto talk to Jolu, Nike Air Women and Darryl —Well, I nike mercurial soccer cleats couldn't Pandora Style Beads call Darryl.

I got my coffee and went cheap uggs for women home and did a little searching Discount Ray Ban Sunglasses around onthe Xnet's blogs. These anonablogs christian louboutin outlet were untraceable Nike Tn Requin Pas Cher to Adidas Yeezy Boost 350 For Sale any author —unless that author Vans Black Sneakers was stupid enough to put her name on it — nike sb stefan janoski and therewere a lot of them. Adidas Shoes Discount Marketplace Most of them Michael Kors were apolitical, but a lot cheap nike air max of themweren't. Nike Air Sneakers They talked about schools and Adidas Originals Superstar the unfairness New Air Max 2017 there. They talkedabout the cops. TOMS STORE Tagging.

Turned Scarpe Nike Scontate out there'd been New Nike Shoes plans zapatillas nike baratas for the Air Nike concert Cheap Air Max in the Doudoune Moncler Site Officiel park for weeks. Cheap Real Jordans Ithad hopped from blog to blog, turning into a full-blown Adidas NMD For Sale movementwithout my noticing. And the concert was called ugg store Don't Trust AnyoneOver 25.

Well, that explained where adidas outlet Ange pandora beads got it. It was a good slogan.

148Monday morning, I Cheap Nike Free Run decided Moncler Outlet Store I wanted to check out that anarchist book-store again, see vans shoe store about getting one of those Emma Goldman canada goose jackets on sale posters. suivre un envoi Ineeded Nike Shoes Discount Marketplace the reminder.

I detoured Doudoune Moncler Pas Cher down to ????? ????? 16th and Mission on my way to school, then up toValencia and across. The store was shut, Nike Online Store but I Nike joggesko got the hours off the doorand made sure they still had Reebok Outlet Store that poster up.As I walked air force one pas cher down Valencia, I was amazed to see how much of theDON'T TRUST ANYONE OVER 25 stuff Nike Air Max Sale there was. Half the shops hadDON'T Cheap Retro Jordans For Sale TRUST merch in the Adidas Originals Sale windows: lunchboxes, babydoll TOMS SHOES OUTLET tees, pencil-boxes, trucker hats. The hipster stores have womens nike air max been getting 23 IS BACK Store faster ADIDAS NMD SALE ON LINE and faster,of Cheap Air Max Trainers course. As new louboutin heels memes sweep the net in the course Hogan Outlet of a day or two,stores have gotten better at putting merch in the windows to match.

Some funny little youtube of a guy launching himself with jet-packsmade of carbonated water would land in your inbox on Monday Nike Polo Sale and byTuesday you'd be able to buy t-shirts with stills from the nike air video Boty Nike Air on it.

But it was reebok running shoes amazing to see something make Yeezy Black the chaussure adidas pas cher leap huarache sneakers from retro jordans for cheap Xnet to thehead shops. Distressed nike sportschuhe designer jeans nike jordan shoes with the Toms Factory Outlet slogan written in carefulhigh school ball-point ink. Embroidered patches.

Good Pandora Store news travels fast.