Subscribe to RSS feed  Follow @jackvamvas - Twitter

*Use the Comments section for questions Links


SQL Server DBA Jobs

DBA Scripts that are proven to solve SQL Server problems

03 October,2012 by Tom Collins

There are powerful DBA scripts available for DBAs in this post that will help you build a strong foundation in managing  Database Servers. The scripts cover : sql server performance tuning scripts, backup database sql server script, sql server dba basics


I’ll keep adding more DBA scripts to this post.

Last Updated  26th May 2023


AWS Database Migration Services (DMS) SQL Server to PostgreSQL

List Foreign Keys referencing tables in SQL Server

What are the triggers in SQL Server

How to find all identity columns in SQL Server

How to find default values of all SQL Server columns

How to find computed columns on a SQL Server table

Find SQL Server LOB Columns

How to List all indexes of all SQL tables

How to find SQL Filtered Indexes

Find LOB tables with no PRIMARY KEY

How to find UDT on SQL Server columns?

How to find all tables with primary key SQL Server

Troubleshooting problems in SQL Server

SQL Server Blocking Reading List

Current queries executing on SQL Server

Find sql text in active query with a sql derived table

Who made DDL table changes on the database.

Cached blocking history with sys.dm_db_index_operational_stats

Monitoring a SQL Rollback and sys.dm_exec_requests

Last time a SQL Server stored procedure was executed

SQL Server Error Log Check

SQL Blocking script

How to find MSDB Suspect pages table and bad pages  New

How to find SQL Server Open Transactions New

Use sys.dm_tran_locks to find requests waiting for an exclusive lock

How to monitor Blocked Processes with SQL Alert and email sp_whoisActive report

Security Management

How to list logins mapped to a database in SQL Server

How to get user security changes with SQL default trace New

How to Script database role permissions and securables

SQL Server - Find sql database users and Find database roles

SQL Database roles and members

SQL Server - Orphaned users and how to Synchronise Users and Logins after SQL Server 2005 restore

SQL Server - List all SQL Server users

Find database users mapped to db_owner role 

How to List SQL logins and database user mappings

SQL Server Performance Management

SQL Index Usage


SQL Server – Find tables with page locks using sys.dm_db_index_operational_stats

SQL Server – Find high impact queries with sys.dm_exec_query_stats

SQL Server – Performance Top Queries by Total CPU Time 

Find Table Scans in Query Plan Cache

SQL Script : How to find Nested Loops in Execution Plans for a specific table New

How to find Longest running queries in SQL Server New


Backup\Restore Management

SQL Server - Predict SQL BACKUP DATABASE finish time with sys.dm_exec_requests

SQL Server – Restore Database Estimated Finish Time

How to display sql restore history for a single database

SQL Server - Display sql backup history for a single database

SQL Server - Move MDF/LDF files to a designated path

SQL Server - BackUp All Databases

SQL Server BACKUP folder in windows registry

SQL Server – How to Predict the DBCC SHRINKDATABASE finish time 

Script to check if a SQL database has a backup New


Index Management

SQL Server - How to find the largest sql index and table size

SQL Server - Predict ALTER INDEX REORGANIZE finish time

SQL Server Disable Indexes and Rebuild Indexes dynamically

SQL Index Fragmentation and sys.dm_db_index_physical_stats

SQL Server - Index missing Statistics

SQL Server - List all indexes of all tables


SQL Server - Delete all statistics from a table

SQL Server Update Statistics with FULL SCAN

SQL Server - sp_MSforeachtable

SQL Index Usage


Object Management

How to get the SQL View definition

How to list CLR objects inside a SQL Server database New

SQL Server - Find the Database File Size and Log File Size

SQL Server – sys.master_files and list all database files

SQL Server - DBCC checktable

SQL Server – refresh all Views

SQL Server - Table sizes and percentages

SQL Server - All tables row count

List Foreign Key Constraints -MS SQL

SQL Server Database size Check

Search for text in stored procedures

OpenXML - more than 8000 characters

SQL Server – Check Data and Log files are on separate drives

SQL Server – Get sql table size and last updated for all tables

SQL Server – Find last time of update on a table

How to predict DBCC CHECKDB finish time New


SQL Server Database Size and Free Disk Space Daily Report

SQL Server - Space used for all databases

SQL Server - Space Integrity Check


SQL Server Agent

SQL Server Agent Job Steps - SQL Server DBA



SQL Server – List current tempdb statements New


Query VMWare vCenter VCDB database for guest power state = OFF new

SQL Query to check Vmware cpu and memory overcommit  New

How to find VMWare ESX Host event messages using VPXV_EVENTS 

Query VMWare vCenter VCDB database for guest and host details 

Extended Events

How to capture SQL login details with Extended Events

How to capture SQL Server database RESTORE details with Extended Events

How to capture query errors using SQL Server Extended Events ...

How to Audit user DML with SQL Server Extended Events (SQL ...

How to read and parse the Microsoft SQL Server extended event log ...

How to capture query errors using SQL Server Extended Events


SQL Server - Sp_send_dbmail and bcc

If you're looking for Powershell scripts to manage SQL Server Click here for  Powershell scripts 


Copyright c 2023 – All rights reserved. No

part of these scripts may be reproduced, translated, posted or shared in any

form, by any means.

The information provided in this post is provided "as is" with no implied

warranties or guarantees.


Author: Tom Collins (


Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.


Post a comment on DBA Scripts that are proven to solve SQL Server problems | SQL Server Performance Tuning | SQL Server DBA:Everything | FAQ | Contact|Copyright & Disclaimer