Back

SQL DBA Script All in One

SQL Server Performance Tuning Scripts

We can learn that all databases CPU resources usage with following script.

You can find TOP CPU queries in SQL Server database with following query.

You can find TOP CPU queries in SQL Server database with following query.

You can find TOP 50 IO queries in SQL Server database with following query.

You can find TOP IO queries in SQL Server database with following query.

To see IO stats and following information you can execute below script.

SQL Monitoring Scripts

You can monitor running queries in SQL Server with following script.

SQL Server Blocking and Lock Scrips

To find blocking sessions or queries, execute following script. If blocking query are not ended in a short time, you can kill it after asking customer.

Backup Check

Backup should be checked everyday by SQL Server DBA with following script.

Index Maintenance Scripts

You can check fragmented index with following script. Type SQL Server Database name is correctly in the first line then query will find fragmented indexes.

You can find all indexes usage statistic with following script.

Database Objects Statistics

You can check all database objects stats with following query.

Active Sessions and Status

You can use whoIsActive and following script for monitoring all sessions status.

SQL Server Wait Events

You can get list and status of currently waiting tasks with following script.

You can find wait events of database with following query.

You can find wait events of database with following query.

SQL Database Size

You can analyse the database size growth using backup history with following script.

Partitioning Check

You can check if table is partitioned in SQL Server with following query.

Inventory Collection Script

Inventory Collect Query is like following, it will make your job very simplify when you connect to any SQL Server database for the first time.

Query is like following, it will make your job very simplify when you connect to any SQL Server database for the first time.

Inventory Collect Query is like following, it will make your job very simplify when you connect to any SQL Server database for the first time.

Reference: www.ittutorial.org