SQL Server Scripts
open-menu closeme
Home
All SQLServer70 Scripts
Scripts & Commands
Links icon
SQL Server Documentation SQL Server Mgmnt Studio
About
Contact Us
Privacy Statement
rss
  • SQL Server Kill Sessions: Filtered SPID Management

    calendar Apr 11, 2026 · 9 min read · sql server session management kill spid database administration dm exec sessions maintenance scripts sql scripts database connections active sessions open transactions  ·
    Share on: twitter facebook linkedin copy

    Kill SQL Server Sessions with Targeted Filters Using KILL and dm_exec_sessions This article covers a practical T-SQL script that kills one or more SQL Server sessions (SPIDs) while giving you precise control over which sessions are targeted. The script uses sys.dm_exec_sessions to query active sessions and a cursor to …


    Read More
  • SQL Server Backup Status Report: All Databases

    calendar Apr 10, 2026 / Apr 11, 2026 · 7 min read · sql server database administration backup recovery maintenance scripts msdb sql scripts database management backup monitoring full backup differential backup transaction log backup  ·
    Share on: twitter facebook linkedin copy

    Check SQL Server Backup Age Across All Databases This script queries the SQL Server backup history catalog to report the most recent full, differential, and transaction log backup for every database, including how many hours and minutes ago each backup completed. Purpose and Overview Database backups are your last line …


    Read More
  • SQL Server Verify Backup Files: RESTORE VERIFYONLY

    calendar Apr 6, 2026 / Apr 11, 2026 · 8 min read · sql server backup recovery database administration maintenance scripts restore verifyonly msdb sql scripts database management backup validation msdb.dbo.backupset msdb.dbo.backupmediafamily  ·
    Share on: twitter facebook linkedin copy

    Verify SQL Server Backup Files with RESTORE VERIFYONLY Backup files that cannot be restored are worthless, and many DBAs discover problems only when they attempt an actual restore under pressure. The scripts in this article use RESTORE VERIFYONLY to confirm that backup files are readable and internally consistent …


    Read More
  • SQL Server Point-in-Time Restore with STOPAT

    calendar Apr 5, 2026 / Apr 11, 2026 · 8 min read · sql server restore backup recovery transaction log msdb database maintenance DBA scripts point in time restore  ·
    Share on: twitter facebook linkedin copy

    Recover a SQL Server Database to a Specific Point in Time SQL Server's RESTORE LOG ... WITH STOPAT lets you roll a database back to any exact moment covered by your backup chain. This guide walks through querying backup history in msdb, executing the restore sequence, and verifying the result. Purpose and Overview Data …


    Read More
  • SQL Server Blocking Detection: Find Blocked Sessions

    calendar Mar 1, 2026 / Apr 11, 2026 · 5 min read · sql server blocking performance dm exec requests dm exec sessions wait types dba scripts monitoring query tuning  ·
    Share on: twitter facebook linkedin copy

    Blocking in SQL Server occurs when one session holds a lock that another session needs, causing the second session to wait. This T-SQL script queries the dynamic management views to show all currently blocked sessions, the blocking session, wait type, wait duration, and the SQL text involved. Purpose and Overview When …


    Read More
  • SQL Server Missing Indexes Report: dm_db_missing_index

    calendar Feb 28, 2026 / Apr 11, 2026 · 6 min read · sql server missing indexes performance dm db missing index details dm db missing index group stats index tuning dba scripts query optimization  ·
    Share on: twitter facebook linkedin copy

    SQL Server tracks index recommendations automatically as queries execute, storing them in the missing index DMVs. This T-SQL script queries those views to produce a ranked report of missing indexes, ordered by the estimated improvement they would provide, along with a ready-to-run CREATE INDEX statement for each …


    Read More
  • SQL Server Wait Statistics Report: dm_os_wait_stats

    calendar Feb 27, 2026 / Apr 11, 2026 · 6 min read · sql server wait statistics performance dm os wait stats wait types bottleneck analysis dba scripts performance tuning  ·
    Share on: twitter facebook linkedin copy

    Wait statistics are one of the most reliable ways to identify performance bottlenecks in SQL Server. This T-SQL script queries sys.dm_os_wait_stats, filters out background and idle wait types that do not indicate real problems, and ranks the remaining waits by their percentage of total wait time. Purpose and Overview …


    Read More
  • SQL Server Primary Key Discovery Script: sp_pkeys Guide

    calendar Aug 9, 2025 / Apr 11, 2026 · 3 min read · sql server primary keys database administration scripts sysobjects sp_pkeys dynamic sql sysobjects sys.tables sys.key_constraints INFORMATION_SCHEMA.TABLE_CONSTRAINTS  ·
    Share on: twitter facebook linkedin copy

    SQL Server Primary Key Discovery Script Using sp_pkeys and sysobjects Purpose This SQL Server script generates dynamic SQL statements that can be executed to discover primary keys across all user tables in a database. It's a powerful administrative tool that helps database administrators quickly identify primary key …


    Read More
  • SQL Server: Find Tables with Clustered Indexes for Rebuild

    calendar Aug 9, 2025 / Apr 11, 2026 · 3 min read · sql server clustered indexes database maintenance index rebuilding system tables dba scripts performance tuning database administration sysobjects sysindexes sys.tables sys.indexes  ·
    Share on: twitter facebook linkedin copy

    SQL Server Query to Identify Tables with Clustered Indexes for Rebuilding Database administrators frequently need to perform maintenance operations on clustered indexes to optimize database performance. This SQL Server query provides a quick and efficient way to identify all user tables that contain clustered indexes, …


    Read More
  • SQL Server Object Permissions: Generate GRANT Statements

    calendar Aug 8, 2025 / Apr 11, 2026 · 5 min read · sql server database security permissions grant statements database administration sql scripts security database objects sysobjects  ·
    Share on: twitter facebook linkedin copy

    SQL Server Object-Level Permissions Script: Generate GRANT Statements for Database Security Database security is a critical aspect of SQL Server administration, and managing permissions at the object level can be time-consuming when done manually. This SQL Server script automates the process of generating GRANT …


    Read More
    • ««
    • «
    • 1
    • 2
    • 3
    • »
    • »»

SQLServer70.com

Your Source for SQL Server Scripts
Read More

Recent Posts

  • SQL Server Kill Sessions: Filtered SPID Management
  • SQL Server Backup Status Report: All Databases
  • SQL Server Verify Backup Files: RESTORE VERIFYONLY
  • SQL Server Point-in-Time Restore with STOPAT
  • SQL Server Blocking Detection: Find Blocked Sessions
  • SQL Server Missing Indexes Report: dm_db_missing_index
  • SQL Server Wait Statistics Report: dm_os_wait_stats
  • SQL Server Primary Key Discovery Script: sp_pkeys Guide

Categories

SCRIPTS 18 SQL SERVER ADMINISTRATION 3 SQL SERVER BACKUP RECOVERY 3 SQL SERVER MAINTENANCE 3 SQL SERVER MONITORING 3 SQL SERVER PERFORMANCE 3 SQL SERVER STRUCTURE 2 SQL SERVER SECURITY 1

Series

ADMIN-GUIDE 18

Tags

SQL SERVER 17 DATABASE ADMINISTRATION 11 SYSOBJECTS 10 SQL SCRIPTS 7 SYS.TABLES 7 DATABASE MAINTENANCE 6 DBA SCRIPTS 6 PERFORMANCE TUNING 5 DBCC COMMANDS 4 MAINTENANCE SCRIPTS 4 PERFORMANCE 4 DATABASE MANAGEMENT 3 MSDB 3 SCRIPTS 3
All Tags
ACTIVE SESSIONS1 ADMINISTRATION2 AUTOMATION2 BACKUP1 BACKUP MONITORING1 BACKUP RECOVERY2 BACKUP VALIDATION1 BLOCKING1 BOTTLENECK ANALYSIS1 CLUSTERED INDEXES1 CURSOR PROGRAMMING1 DATABASE1 DATABASE ADMINISTRATION11 DATABASE CONNECTIONS1 DATABASE MAINTENANCE6 DATABASE MANAGEMENT3 DATABASE MONITORING2 DATABASE OBJECTS1 DATABASE OPTIMIZATION1 DATABASE SCRIPTS1 DATABASE SECURITY1 DBA SCRIPTS6 DBA TOOLS1 DBCC1 DBCC CHECKIDENT1 DBCC COMMANDS4 DBCC DBREINDEX2 DIFFERENTIAL BACKUP1 DM DB MISSING INDEX DETAILS1 DM DB MISSING INDEX GROUP STATS1 DM EXEC REQUESTS1 DM EXEC SESSIONS2 DM OS WAIT STATS1 DYNAMIC SQL2 FRAGMENTATION1 FULL BACKUP1 GRANT STATEMENTS1 IDENTITY COLUMNS1 INDEX OPTIMIZATION1 INDEX REBUILDING1 INDEX TUNING1 INDEXING1 INFORMATION_SCHEMA.TABLE_CONSTRAINTS1 INFORMATION_SCHEMA.TABLES1 KILL SPID1 MAINTENANCE SCRIPTS4 MISSING INDEXES1 MONITORING1 MSDB3 MSDB.DBO.BACKUPMEDIAFAMILY1 MSDB.DBO.BACKUPSET1 OPEN TRANSACTIONS1 OPTIMIZATION2 PERFORMANCE4 PERFORMANCE TUNING5 PERMISSIONS1 POINT IN TIME RESTORE1 PRIMARY KEYS1 QUERY OPTIMIZATION1 QUERY TUNING1 RECOVERY1 RESTORE1 RESTORE VERIFYONLY1 SCRIPTS3 SECURITY1 SESSION MANAGEMENT1 SP_PKEYS1 SP_SPACEUSED1 SPACE MANAGEMENT1 SQL1 SQL SCRIPTS7 SQL SERVER17 STATISTICS1 SYS.ALLOCATION_UNITS1 SYS.INDEXES1 SYS.KEY_CONSTRAINTS1 SYS.PARTITIONS1 SYS.TABLES7 SYSINDEXES2 SYSOBJECTS10 SYSTEM TABLES3 T-SQL2 TABLE ANALYSIS1 TABLE STATISTICS1 TRANSACTION LOG1 TRANSACTION LOG BACKUP1 UPDATE STATISTICS1 WAIT STATISTICS1 WAIT TYPES2
[A~Z][0~9]
SQLServer70.com

Copyright  SQLSERVER70.COM. All Rights Reserved

to-top