SQL Server Health Check HTML Report

SQL Server Health Check HTML Report

Report Overview

SQL Server Health Check HTML Report is the improved version of the old report and it can help you to quickly monitor the health of a given SQL Server instance. This report fetches and process the data from system tables and dynamic management views. It reports the crucial factors that showcase the current database instance performance. It’s been written using T-SQL script. We can run it on any SQL Server instance starting from 2008 R2 to 2019. Save the result as .HTML format and the same can be viewed through any web browser. We neither tested it on Azure nor RDS instances, thereof we may need to do some code changes for cloud instances. Script download is available at the end of this post.

Report Parts

Report contains below parts:

  • SERVER DETAILS
  • INSTANCE INFORMATION
  • DISK SPACE USAGE
  • TEMPDB USAGE
  • CPU USAGE
  • MEMORY USAGE
  • PERFORMANCE COUNTER DATA
  • MISSING BACKUP REPORT
  • DATABASE CONNECTIONS
  • DATABASE LOG SPACE USAGE
  • SQL AGENT JOB STATUS
  • BLOCKING PROCESS INFORMATION
  • LONG RUNNING TRANSACTIONS
  • TOP 20 TABLES
  • INDEX ANALYSIS
  • SQL ERRORLOG

Execution Procedure

  1. Create the stored procedure “[usp_SQLhealthcheck_report]”
  2. Execute the procedure Ex: EXECUTE [usp_SQLhealthcheck_report];
  3. Pass Mail profile and Email details @MailProfile, @MailID. Not mandatory
  4. Save Result As: Save output as .HTML on your local
  5. Make sure that the saved report is on the same folder where Images folder exists. So that we can see the LOGO at right corner.

Output Format

  1. Direct HTML report
  2. Send email with HTML as an attachment

Critical Performance Counter Data

This section captures the critical performance counters from management views. Some of those counters plays the vital role in system performance evaluation.

Page Life Expectancy (PLE): How many seconds a page is being available in Memory.

Buffer Cache Hit Ratio (BHR): What is the percentage of database calls reaching Buffer Cache instead of Disk storage.

Grants Pending: If any Memory requests pending from OS

Memory Low Alerts: 0 indicates no such alerts registered.

Recommendation for Continues Monitoring

If we want to design performance trends, then I would recommend the below parameters for monitoring on continues basis:

CPU Usage

  • SQL Process Utilization
  • System Idle

Memory Usage

  • Total_Physical_Memory_MB
  • Physical_memory_in_use_GB

Performance Counter Data

  • Page Life Expectancy
  • Buffer Cache Hit Ratio
  • Memory Grants Pending
  • Memory Grants Outstanding
  • Process_Physical_Memory_Low
  • Process_Virtual_Memory_Low

Blocking Process Information

Sample Screenshots from HTML Report:

Create procedure on the required database:

Execute the procedure. I don’t need to send email rather just need a HTML report

SQL Server Health Check HTML Report

Store the output as in HTML report

SQL Server Health Check HTML Report SQL Server Health Check HTML Report SQL Server Health Check HTML Report

Create Images folder and create the required company logo and name it as Logo_Image.jpg

SQL Server Health Check HTML Report

Open the report in a web browser, Sample Screenshots

SQL Server Health Check HTML Report SQL Server Health Check HTML Report SQL Server Health Check HTML ReportSQL Server Health Check HTML ReportSQL Server Health Check HTML Report SQL Server Health Check HTML Report SQL Server Health Check HTML Report SQL Server Health Check HTML Report

Summary:

SQL Server Health Check HTML Report is useful to quickly get the performance snapshot of a database instance. After going through the overall system parameters, except the minor issues we can clearly state that the both instances are optimally performing. Index maintenance and the database log file maintenance are the critical activities to be considered. Please make note that the HC report tool is not reporting the SQL code issues and its scope is restricted to the database system level performance.

Note:

  1. Always test the script on Pre-Production environment
  2. Top 20 Tables may take some time for VLDB
  3. You can customize the script based on requirement

SQL Server Health Check HTML Report

Posted in Performance Tuning, SQL Scripts, SQL Server DBA | Tagged , , , , , | 49 Comments
Subscribe
Notify of
guest
49 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Manasa Alluri
Manasa Alluri
4 years ago

I just executed it on my machine and it’s generating a HTML report just like a magic.
Such an altruistic attitude. We’ll get paid, if we provide the same report to any of our clients.
You are awesome sir. It will be very helpful in handling incidents.

Thank you so much sir.
–Manasa

Abdo
Abdo
3 years ago
Reply to  Manasa Alluri

Please i need the script

Subrahmanin
Subrahmanin
4 years ago

We are already using the old script that you provided earlier. This looks amazing sir. I am going to update my old one with the latest code. I think I need your help in displaying my company logo on report. Loved the HTML format. Sir, you are my SQL Hero 🙂

Sriram Kumar
Sriram Kumar
4 years ago

It’s really helpful. Thank you so much Uday.
I need to have some customer specific datafeed status report on this healthcheck. Can you please help me out in adding that to the base code?

Thanks again for sharing the wonderful script.

Sriram

Thomas
Thomas
4 years ago

where is the script?

Sreeni Reddy
Sreeni Reddy
4 years ago

Your script is a piece of cake. Really helpful to all.
If possible please include below ones too.
*** List of OFFLINE/SUSPECT databases on all SQL Servers ***
*** Newly created Logins during last 24 hours ***
*** Newly created databases during last 24 hours ***

soni
soni
4 years ago

Hi, thanks for the good script, but its not include/check the database inside the server/instance. pls can you tell me how to also check the database inside the instance.

Thanks

Naresh
Naresh
3 years ago
Reply to  soni

Yes, It’s helpful if it include database name

Suresh
Suresh
4 years ago

Hi Sir,
What an excellent report in HTML format with details and it is very much useful to monitor SQL server health.
Thanks a lot for providing this script.
However, when I am trying to modify or alter the SP, getting below error i.e text is encrypted. Please help me on this.
Property TextHeader is not available for StoredProcedure ‘[dbo].[usp_SQLhealthcheck_report]’. This property may not exist for this object, or may not be retrievable due to insufficient access rights. The text is encrypted.

Suresh
Suresh
4 years ago
Reply to  uday arumilli

Many thanks for your response.
Now I am able to modify.

Vedprakash Sharma
Vedprakash Sharma
4 years ago

Hi All,
How can we send this report in email body.

Sivakrishna
Sivakrishna
4 years ago

Could you help with including database parameters as well? Also, how to send this report by email.

Praveen
Praveen
4 years ago

Hi Sir,
The script is nice and helpful to do the health checks quickly ….. can we run the script outside of the server and if we pass the SQL instance it should get the results for that server ? is it possible ?
When i tested the script of passing the different SQL server instance names, the health report is generating only for local server not for remote servers.

peiris
peiris
4 years ago

You have not noted the way to create stored procedure. Please guide for that

PMP
PMP
4 years ago

Standard visits recorded here are the simplest strategy to value your vitality, which is the reason why I am heading off to the site regular, looking for new, fascinating information. Many, bless your heart!

PMP

hrdf claimable training

I think this is an extraordinary article. You make this information interesting and secures. You give perusers a lot to consider and I esteem such a forming.
<a href=”https://360digitmg.com/hrdf-scheme”>hrdf claimable training</a>

360DigiTMG data analytics course

A decent blog consistently concocts new and energizing data and keeping in mind that perusing I have feel that this blog is truly have each one of those quality that qualify a blog to be a one.
<a href=”https://360digitmg.com/course/data-analytics-using-python-r”>360DigiTMG data analytics course</a>

pmp certification in malaysia
pmp certification in malaysia
4 years ago

I like this post,And I figure that they making some incredible memories to scrutinize this post,they may take a good site to make an information,thanks for sharing it to me
<a href=”https://360digitmg.com/course/project-management-professional-pmp”>pmp </a>certification in malaysia 

difference between analysis and analytics

Set aside my effort to peruse all the remarks, however I truly delighted in the article. It’s consistently pleasant when you can not exclusively be educated, yet in addition, engaged!<a href=”https://360digitmg.com/what-is-the-difference-between-analysis-and-analytics”>difference between analysis and analytics </a>

sreeharsha
sreeharsha
4 years ago

I have been following your site sir and mostly i used your script to dig into the issues. Now health check scripts its amazing.
Saying thank you to you is just small word.

hrdf contribution
hrdf contribution
4 years ago

This is a great motivational article. In fact, I am happy with your good work. They publish very supportive data, really. Continue. Continue blogging. Hope you explore your next post
<a href=”https://360digitmg.com/hrdf-training”>hrdf contribution</a>

Brett
Brett
4 years ago

Wow, this is awesome stuff. Just one question, I am using the email parameters which work perfectly. I am just wondering if i can embed a logo in the emails somehow.

Ashutosh
Ashutosh
3 years ago
Reply to  uday arumilli

Hi Uday Sir,
How we can share this health check report on email and is the any specific permission/port is required. please suggest or please share the script

Sravan
Sravan
4 years ago

The script executed successfully on few servers but when I try to run on similar other 2 servers getting below error, please help me on that. Msg 137, Level 15, State 1, Procedure SQL_DB_healthcheck_report, Line 701 Must declare the scalar variable “@OriServer”. Msg 137, Level 15, State 2, Procedure SQL_DB_healthcheck_report, Line 702 Must declare the scalar variable “@SERVERNAME”. Msg 137, Level 15, State 2, Procedure SQL_DB_healthcheck_report, Line 737 Must declare the scalar variable “@version”. Msg 137, Level 15, State 2, Procedure SQL_DB_healthcheck_report, Line 1087 Must declare the scalar variable “@SERVERNAME”. Msg 137, Level 15, State 2, Procedure SQL_DB_healthcheck_report, Line 1275… Read more »

Vishal
Vishal
4 years ago

There is no option to save report on local disk we have to manually save store procedure output in HTML format.

Jagan
Jagan
3 years ago

Can you please help on to get all the drives with total size, free size and percentage_freespace..
Checked many blogs.. didnt get

Jegan
Jegan
3 years ago

It’s really helpful. Thank you so much Uday.

yash
yash
3 years ago

Many Many Thank you for this script, I just want to know that is this script will work for DB server on which AG is configured, because backup scenario is little bit different in AGs

Rajesh
Rajesh
3 years ago

Index Analysis & Top 20 Tables data has not been fetching from all DBs hosted on an instance of SQL Server. It is fetching data from DB where stored procedure is resides under and is working in the context of that DB alone.
Great work Uday!!

Sinu
Sinu
3 years ago

I have scheduled in the job but getting failed

Date 3/16/2021 3:21:52 PM
Log Job History (checklist)

Step ID 1
Server SERVER2
Job Name checklist
Step Name EXECUTE master.dbo.usp_SQLhealthcheck_report
Duration 00:00:00
Sql Severity 0
Sql Message ID 0
Operator Emailed
Operator Net sent
Operator Paged
Retries Attempted 0

Message
The step is improperly defined (it needs a valid command) and so could not be run. The step failed.

Sourav Misra
Sourav Misra
3 years ago

How to get Top 20 tables and Index Fragmentation Details for all databases.

Sree
Sree
3 years ago

any changes needed to make this work on azure sql paas (elastic pool)

vamsi
vamsi
3 years ago

Really thanks for the script. It helped a lot.
only problem for me is the Index fragmentation details. It seems not pulling for me on user databases. when i try to run the script in a database it works but when i run the SP it shows blank. Any help to fix this is really appreciated.

Ananda
Ananda
3 years ago

Thanks Udaya for sahring HC script.
this is really excellent script for using database health checks on daily basis. working script awesome without any glitch.

Dilip Vishwakarma
Dilip Vishwakarma
3 years ago

Hello,
For multiple servers, I will be getting mails for each servers or we can configure in a way that only one mail will be recevied for approx. 60 Servers, Please suggest

mohamed anas
mohamed anas
3 years ago

Hi Sir,

Amazing script , I’m late to noticed this cool stuff. Please guide me how to configure this script via email.

Thanks,
Anas

Last edited 3 years ago by mohamed anas
Vivek
Vivek
3 years ago

Hi Uday,
Lovely set up and report Output. But not sure why Index Defrag is not giving any output?
Also; how can we run it for multiple servers in one go? it seems currently we have run it on every server individually.

Anji
Anji
3 years ago

Thank you for sharing good script.
can you please add below logic if possible?

  1. need index analysis on all databases
  2. top huge tables on all databases
  3. save the output file directly to a folder with .HTML

Thanks
Anji

sri
sri
2 years ago

most of the report doesnt work on azure sql database (paas with elastic pool) any insight?

Suma
Suma
2 years ago

excellent script and looks so detailed. Thanks a lot. It made so easy . But request you to share an updated script with background color that changes according to the result. For suppose, if the disk space is less and need to take action then it should be warned with a background color red and incase more space is available then should be shaded with background color green. Also, I’m bit confused why the “Index Analysis” & “Top 20 Huge Tables” were not resulting in any of the server. Is there any modification to be done in the script. ?… Read more »

SeethaRamaiah T
SeethaRamaiah T
2 years ago

Nice script bro… it’s helped alot….. total server and used memory details are not getting

Last edited 2 years ago by SeethaRamaiah T
karthi
2 years ago

Thanks for your report. It is working fine in sql server 2012. But, It is not displaying any information for the following columns in sql 2019 server. I tried in one of the databases which has lot of I/O and active connections for many databases.
SQL Agent Job StatusBlocking Process InformationLong Running TransactionsTop 20 Huge TablesIndex AnalysisSQL ErrorLog

srini
srini
2 years ago

Hi Uday
Please add DB Properties and drive related total space and free space with percentage in script.
Thank you.