SQL Server Copy-Only Backup Script for Dev Restore
Apr 20, 2026 / · 6 min read · sql server backup recovery copy only backup t-sql database administration msdb sql scripts dev restore ·A copy-only backup is a special SQL Server backup that is independent of the normal backup sequence. It does not reset the differential base or interrupt the transaction log backup chain, making it the correct choice when you need an ad-hoc backup for a development or test environment restore without affecting …
Read MoreSQL Server: Find Databases With No Recent Backup
Apr 19, 2026 / · 6 min read · sql server backup recovery msdb monitoring database administration sql scripts backup audit sys.databases ·Finding databases that have not been backed up recently is one of the most important checks a DBA can run. A database that grows unnoticed without a backup is a data loss event waiting to happen. This script queries msdb.dbo.backupset against sys.databases to surface any online user database with no full backup in the …
Read MoreSQL Server Foreign Keys Without Indexes Script
Apr 18, 2026 / · 6 min read · sql server indexes foreign keys performance sql scripts database structure sys.foreign_keys query optimization ·Foreign keys enforce referential integrity, but SQL Server does not automatically create indexes on the referencing (child) columns. An unindexed foreign key column forces a full table scan every time a join or a DELETE on the parent table triggers a referential check. This script identifies all foreign key columns in …
Read MoreSQL Server Backup Compression: Enable and Verify
Apr 17, 2026 / · 7 min read · sql server backup recovery backup compression sp_configure msdb sql scripts database administration maintenance scripts ·Backup compression reduces the on-disk size of SQL Server backup files and can significantly shorten backup duration by reducing the amount of data written to disk. This post shows how to enable compression at the server level, verify the setting is active, and confirm compression ratios from backup history using the …
Read MoreSQL Server Find Orphan Users Script
Apr 17, 2026 / · 7 min read · sql server security orphan users sys.database_principals sys.server_principals sp_change_users_login database administration sql scripts security audit login management ·Orphaned database users are a common problem after database restores, server migrations, or login deletions. A database user becomes orphaned when its SID does not match any server-level login SID. This script queries sys.database_principals and sys.server_principals to find every orphaned user in a database, and shows …
Read MoreSQL Server MAXDOP Recommendation Script
Apr 17, 2026 / · 6 min read · sql server maxdop performance sp_configure numa sql scripts database administration cpu configuration ·MAXDOP (max degree of parallelism) controls how many CPU threads SQL Server can use for a single parallel query. The default value of 0 allows SQL Server to use all available processors, which can cause large parallel queries to monopolise the server. This script reads the CPU topology from system DMVs and calculates …
Read MoreSQL Server: Find Tables Without Primary Keys
Apr 16, 2026 / · 7 min read · sql server primary keys database structure heap tables sql scripts schema audit performance sys.tables ·Tables without primary keys are heap structures with no guaranteed row ordering and no unique row identifier. They cause full table scans in queries that could use seeks, slow down DELETE and UPDATE operations, and are incompatible with SQL Server replication and Change Data Capture. This script finds every user table …
Read MoreSQL Server Backup History: Duration and Size Report
Apr 13, 2026 / · 6 min read · sql server backup recovery msdb sql scripts database administration backup monitoring maintenance scripts reporting sys.databases backupset ·Query Backup Duration and File Size from SQL Server History This script queries SQL Server's msdb backup history to report the backup type, start and finish time, duration in minutes, and file size in both megabytes and gigabytes for every backup across all user databases on the server. Purpose and Overview Knowing …
Read MoreSQL Server Long-Running Queries: Find Active Sessions
Apr 12, 2026 / · 6 min read · sql server performance monitoring sql scripts sys.dm_exec_requests sys.dm_exec_sql_text blocking wait types database administration active sessions ·Find Active Long-Running Queries in SQL Server This script queries sys.dm_exec_requests and sys.dm_exec_sql_text to show all currently executing queries on the SQL Server instance, sorted by how long they have been running, along with CPU time, I/O activity, blocking status, and wait type information. Purpose and …
Read MoreSQL Server Agent Job Failure History Report
Apr 11, 2026 / · 8 min read · sql server sql server agent msdb sql scripts database administration job monitoring maintenance scripts reporting sysjobs sysjobhistory ·Report SQL Server Agent Job Status and Failure History This script queries the SQL Server Agent job history stored in msdb to produce a detailed report of each job's most recent run status, failure and success counts over the last 60 days, total lifetime run counts, and job step information including subsystem type and …
Read More