Tag: SQL Server Scripts

  • Identify Missing & Unused Indexes in SQL Server

    Indexes are crucial for SQL Server query performance. Everyone needs an Index. However, improper indexing strategies can degrade database performance, leading to slow queries and cause resource bottlenecks. Effectively managing indexes involves not only identifying the missing ones that could improve performance, but also pinpointing unused indexes that…

    Read More


  • SQL Server Performance Tuning: Index Fragmentation Scripts

    In this post I’m sharing more scripts to help with SQL Server performance tuning. This time, we’re looking at index and heap fragmentation which are useful for pinpointing inefficiencies on your database. Fragmentation, whether in indexes or heaps, can lead to slower queries, inefficient storage, and increased maintenance…

    Read More


  • SQL Server Performance Troubleshooting Scripts

    When your SQL Server starts to experience performance issues, it’s important to have tools at your disposal to quickly identify and address the root causes. One such tool is having a performance troubleshooting scripts that provides some insights into SQL Server’s current state; including worker threads, running queries,…

    Read More


  • Checking SQL Server Mirroring Health & Latency

    In this blog post I’m sharing info on how to check the health and latency of your Database Mirroring in SQL Server. Monitoring Database Mirroring latency in SQL Server is needed for maintaining database availability and ensuring quick failover readiness. As a DBA we should be monitoring this…

    Read More


  • SQL Server Replication Monitoring Scripts

    In this post I’m sharing scripts and tips that will help you monitor, identify and troubleshoot SQL Server Replication latency and issues. The following is included in this article: 1. Check Latency in Log Reader Agent. 2. Check Latency in Distribution Agent. 3. Check Undistributed Commands. 4. List…

    Read More


  • SQL Script to Get AAG Latency

    In this post, I’m sharing a script that I use frequently as a Production SQL DBA to check Always On Availability Group (AAG) latency. Always On Availability Groups (AAG) are a high-availability and disaster recovery solution in SQL Server, allowing you to synchronize databases across multiple replicas. These…

    Read More


  • Get All Database Sizes & Free Space Info In SQL Server

    Tracking database file sizes and free space within data and log files is an important part of monitoring SQL Server. This information, along with other metrics such as growth events, can help you to better predict and plan for future disk space provisioning needs. The following script provides…

    Read More


  • Searching for a String Across All Tables in SQL Server

    When working with SQL Server, you might need to find where a specific string exists in a database. This is especially useful when working with large or unfamiliar schemas. For example, you may want to check where a value like a username, email, or other data is stored…

    Read More


  • Show Only the Domain of an Email Address in SQL Server

    When performing data analysis of email data in SQL, there’s often a need to show only the domain of an email address. You can use this for things like checking invalid emails or to find out your most populous domains. In this blog post, I’ll show how to…

    Read More


  • Monitoring Database Growth Events in SQL Server

    Database growth events occur when a SQL Server database file reaches its capacity and automatically grows to accommodate more data. These events are configured in the database properties, where you can define growth increments in MB or GB. Properly configuring these settings is important for maintaining performance, as…

    Read More