Scripts and Tools

Ready-to-run T-SQL scripts, PowerShell tools, utilities, and downloadable advisors for SQL Server DBAs.

Sanity Check for Non-Default SQL Server Settings

I didn’t write this script—I found it in my toolbox and believe it originated from a Microsoft MVP. It’s a simple audit that flags non-default SQL Server settings that are known to cause instability or performance problems when changed. Use it to sanity-check inherited servers or vendor builds. The script is read-only; review the output […]

Sanity Check for Non-Default SQL Server Settings Read More »

SQL Server login failures: 17806 + 18452 (“untrusted domain”) — what they mean and how to fix them

If your seeing these in your SQL server error log they all tie together Error 17806, Severity 20, State 14 with text like:SSPI handshake failed with error code 0x8009030c while establishing a connection with integrated security; Reason: AcceptSecurityContext failed. Error 18452, Severity 14, State 1 with text like:Login failed. The login is from an untrusted

SQL Server login failures: 17806 + 18452 (“untrusted domain”) — what they mean and how to fix them Read More »

“AppDomain … created” in the SQL Server error log — what it means and how to troubleshoot

Example message AppDomain 3 (master.sys[runtime].2) created. What this message means (plain English) SQL Server hosts the .NET Common Language Runtime (CLR). When SQL Server needs CLR—for a user assembly or for certain built-in features—it spins up an AppDomain, which is an isolation container inside the SQL Server process where CLR code runs. That log line

“AppDomain … created” in the SQL Server error log — what it means and how to troubleshoot Read More »

A Practical Guide to Proving Index Needs in SQL Server

When tuning queries in SQL Server, one of the most common tasks is identifying where indexes are missing (or poorly designed) and proving that new indexes will actually improve performance. Tools like SolarWinds DPA or other monitoring solutions can highlight issues, but sometimes you need to go deeper and use the built-in DMVs and query

A Practical Guide to Proving Index Needs in SQL Server Read More »

Building an SSIS Multi-Server Health Sweep with Automated Email Reports

Building an SSIS Multi-Server Health Sweep with Automated Email Reports – SQLYARD Leave a Comment / Articles, SQL Server Features / By SQLYARD Building an SSIS Multi-Server Health Sweep with Automated Email Reports By SQLYARD · SQLYARD.com · May 2026 · Estimated read: 25–30 min If you are responsible for multiple SQL Server instances, one

Building an SSIS Multi-Server Health Sweep with Automated Email Reports Read More »

Idle Blockers in SQL Server: The Silent Killers of Concurrency

Imagine this: a session in SQL Server isn’t running any queries, it’s sitting idle, yet it’s blocking everyone else. That, my friends, is an idle blocker. In this post we’ll cover: 🧠 What Is an Idle Blocker? An idle blocker is a SQL Server session (SPID) that: You’ll usually see it as a session in

Idle Blockers in SQL Server: The Silent Killers of Concurrency Read More »

SQL Server Audit Schema Changes – Part 3: DDL Changes Logged to a Table Using Service Broker

Description In this first part of the SQL Server Audit Schema Changes series, we dive into how to track DDL (Data Definition Language) changes—such as CREATE, ALTER, and DROP statements—by capturing them and logging to a custom table. Learn how to leverage SQL Server’s native features, including DDL triggers and Service Broker, to build a

SQL Server Audit Schema Changes – Part 3: DDL Changes Logged to a Table Using Service Broker Read More »

SQL Server Audit Schema Changes – Part 2: DDL Changes Logged to a Table Using Service Broker

Description:In this first part of the SQL Server Audit Schema Changes series, we dive into how to track DDL (Data Definition Language) changes—such as CREATE, ALTER, and DROP statements—by capturing them and logging to a custom table. Learn how to leverage SQL Server’s native features, including DDL triggers and Service Broker, to build a lightweight,

SQL Server Audit Schema Changes – Part 2: DDL Changes Logged to a Table Using Service Broker Read More »

SQL Server Audit Schema Changes – Part 1: DDL Changes Logged to a Table Using Service Broker

Description:In this first part of the SQL Server Audit Schema Changes series, we dive into how to track DDL (Data Definition Language) changes—such as CREATE, ALTER, and DROP statements—by capturing them and logging to a custom table. Learn how to leverage SQL Server’s native features, including DDL triggers and Service Broker, to build a lightweight,

SQL Server Audit Schema Changes – Part 1: DDL Changes Logged to a Table Using Service Broker Read More »

SQL Server Blocking Detection and Email Notification System: Complete DBA Implementation

SQL Server Blocking Detection and Email Notification System: Complete DBA Implementation – SQLYARD Leave a Comment / Articles / By SQLYARD SQL Server Blocking Detection and Email Notification System: Complete DBA Implementation By David Yard · SQLYARD.com · April 2026 · Estimated read: 18–22 min Table of Contents System Overview Architecture and Components Prerequisites Step

SQL Server Blocking Detection and Email Notification System: Complete DBA Implementation Read More »

Monitoring SQL Server Activity with sp_WhoIsActive

When you need to know what’s running right now on your SQL Server instance, the built-in tools like sp_who or sp_who2 only go so far. That’s where sp_WhoIsActive comes in. sp_WhoIsActive is a widely used diagnostic stored procedure written and maintained by Adam Machanic (SQL Server MVP). It’s free, open-source, and considered by many DBAs

Monitoring SQL Server Activity with sp_WhoIsActive Read More »

SQL Server Extended Event Setup forView Tracing

This document outlines the step-by-step process to set up SQL Server Extended Events totrace a specific view’s execution, capture parameter values, monitor performance, andexport the results to an Excel report. Step 1: Create the Extended EventRun the following script to create an Extended Event session that logs the execution of thespecified view.Replace ‘YourViewName’ with the

SQL Server Extended Event Setup forView Tracing Read More »

PostgreSQL script indice dups and cleanup

You can run this in DBeaver or psql, and it should be safe for inspection — it doesn’t drop anything, just reports. — Unused indexes (not used since last stats reset)SELECTschemaname,relname AS table_name,indexrelname AS index_name,idx_scan,pg_size_pretty(pg_relation_size(i.indexrelid)) AS index_sizeFROMpg_stat_user_indexes uiJOINpg_index i ON ui.indexrelid = i.indexrelidWHEREidx_scan = 0 — Not used at allAND NOT i.indisprimary — Not a

PostgreSQL script indice dups and cleanup Read More »

Glenn’s Performance queries his URL is below for all versions

SQL Server 2022 Diagnostic Information Queries — SQL Server 2022 Diagnostic Information Queries— Glenn Berry— Last Modified: April 1, 2025— https://glennsqlperformance.com/— https://sqlserverperformance.wordpress.com/— YouTube: https://bit.ly/2PkoAM1— Blue Sky: https://bsky.app/profile/glennalanberry.bsky.social — Diagnostic Queries are available here— https://glennsqlperformance.com/resources/ — YouTube video demonstrating these queries— https://bit.ly/3aXNDzJ — Please make sure you are using the correct version of these diagnostic queries

Glenn’s Performance queries his URL is below for all versions Read More »

General Steps for Dropping Foreign Key Constraints When They Are All Referenced

If all your foreign keys are referencing other tables (i.e., they are dependent on primary keys or unique keys in other tables), the process to safely drop these foreign key constraints is still the same. Here’s how to properly approach dropping foreign keys in this scenario: Identify the Foreign Keys: First, determine which foreign keys

General Steps for Dropping Foreign Key Constraints When They Are All Referenced Read More »