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 DBCC Commands: The Complete DBA Reference Guide

    calendar Jun 8, 2026 / Jun 8, 2026 · 6 min read · sql server dbcc commands database maintenance database administration maintenance scripts sql scripts consistency checks DBCC CHECKDB DBCC SHRINKFILE plan cache  ·
    Share on: twitter facebook linkedin copy

    Every SQL Server instance ships with a parallel command vocabulary that never appears in an ORM, a stored procedure, or an application query: the DBCC statements. They validate physical page structure, reclaim file space, evict cached plans, reseed identity columns, and report internal counters that no SELECT exposes — …


    Read More
  • SQL Server DBCC CHECKDB: Complete Guide and Repair Options

    calendar Jun 7, 2026 / Jun 8, 2026 · 6 min read · sql server database corruption consistency checks database maintenance dbcc commands database administration maintenance scripts sql scripts DBCC CHECKDB sys.databases  ·
    Share on: twitter facebook linkedin copy

    Corruption rarely announces itself. A bit flips on a SAN, a controller loses power mid-write, a driver mishandles a flush — and the damaged page sits unread for weeks until a query finally touches it and the database throws error 824. By then the corruption may already be inside every backup you keep. DBCC CHECKDB is …


    Read More
  • SQL Server DBCC FREEPROCCACHE: Clear the Plan Cache Safely

    calendar Jun 6, 2026 / Jun 8, 2026 · 6 min read · sql server plan cache query performance parameter sniffing performance tuning database administration sql scripts dbcc commands DBCC FREEPROCCACHE sys.dm_exec_cached_plans sys.dm_exec_sql_text  ·
    Share on: twitter facebook linkedin copy

    A stored procedure that returned in 20 milliseconds yesterday is timing out today, and nothing in the code changed. The data did not grow meaningfully, the indexes are intact, and statistics look current — yet the query is suddenly scanning a million rows it used to seek. The usual culprit is a cached execution plan …


    Read More
  • SQL Server DBCC SHRINKDATABASE: When and When Not to Shrink

    calendar Jun 5, 2026 / Jun 8, 2026 · 6 min read · sql server database maintenance index fragmentation disk space database administration maintenance scripts sql scripts dbcc commands DBCC SHRINKFILE sys.database_files sys.dm_db_index_physical_stats sys.indexes  ·
    Share on: twitter facebook linkedin copy

    A one-time data load doubled a data file overnight, the load is done, the rows are deleted, and the file is now mostly empty space. The reflex — reach for DBCC SHRINKDATABASE and give the disk back — is one of the most common self-inflicted performance wounds in SQL Server administration. This post explains exactly …


    Read More
  • SQL Server DBCC CHECKIDENT: Check and Reseed Identity

    calendar Jun 4, 2026 / Jun 8, 2026 · 6 min read · sql server identity columns database administration maintenance scripts sql scripts dbcc commands table maintenance identity reseed DBCC CHECKIDENT sys.columns sys.identity_columns  ·
    Share on: twitter facebook linkedin copy

    A logging table grew to forty million rows, the bulk of it was archived out, and now only the last week's data remains — but the next insert still gets identity value 40,000,001, leaving a vast gap below it. Or a botched data load left the seed sitting far above the real maximum, and future inserts skip millions of …


    Read More
  • DBCC DBREINDEX vs ALTER INDEX REBUILD in SQL Server

    calendar Jun 3, 2026 / Jun 8, 2026 · 6 min read · sql server index maintenance index fragmentation database maintenance performance tuning maintenance scripts sql scripts dbcc commands ALTER INDEX sys.dm_db_index_physical_stats sys.indexes sys.objects  ·
    Share on: twitter facebook linkedin copy

    Open the SQL Agent job history on an instance that has been running for a decade and you will still find DBCC DBREINDEX in a nightly maintenance step, quietly doing its job. It works — which is exactly why nobody has touched it. But it has been deprecated for the better part of twenty years, it locks tables it does not …


    Read More
  • SQL Server Duplicate and Overlapping Index Detection Script

    calendar May 25, 2026 / Jun 2, 2026 · 8 min read · sql server indexes duplicate indexes index maintenance index tuning sql scripts sys.indexes sys.objects database administration maintenance scripts sys.dm_db_index_usage_stats sys.index_columns sys.schemas  ·
    Share on: twitter facebook linkedin copy

    Duplicate and overlapping indexes waste storage, slow down every write, and split optimizer statistics across redundant copies. This T-SQL script compares each non-heap index in the current database on its first sixteen key columns and surfaces any pair of indexes that overlap, giving the DBA a short list of cleanup …


    Read More
  • SQL Server Get Table and Index Storage Size Report Script

    calendar May 24, 2026 / Jun 2, 2026 · 7 min read · sql server storage index size table size monitoring sql scripts sys.dm_db_partition_stats sys.indexes sys.tables capacity planning database administration sys.dm_db_index_physical_stats sys.dm_db_index_usage_stats sys.objects sys.partitions  ·
    Share on: twitter facebook linkedin copy

    Knowing how much space each table and each index consumes is the foundation of capacity planning, archive policy, and index cleanup decisions on any SQL Server instance. This T-SQL script reads the partition-level storage statistics out of sys.dm_db_partition_stats and reports the size of every index — clustered, …


    Read More
  • SQL Server Object Dependencies Report: Find All References

    calendar May 23, 2026 / Jun 2, 2026 · 8 min read · sql server dependencies object dependencies database administration refactoring sql scripts sys.sql_expression_dependencies sys.all_objects sys.all_columns impact analysis schema analysis sys.dm_sql_referenced_entities sys.dm_sql_referencing_entities sys.objects  ·
    Share on: twitter facebook linkedin copy

    Before renaming a column, retiring a view, or dropping a stored procedure, every DBA needs the answer to one question: what else depends on this object? This T-SQL script reads sys.sql_expression_dependencies and reports every referencing-and-referenced pair in the current database, with optional filtering to a single …


    Read More
  • SQL Server Find Columns by Data Type Across the Database

    calendar May 22, 2026 / Jun 2, 2026 · 7 min read · sql server columns data types schema analysis sql scripts sys.columns sys.types sys.tables sys.schemas database structure metadata sys.computed_columns sys.dm_db_index_physical_stats sys.foreign_keys sys.objects sys.views  ·
    Share on: twitter facebook linkedin copy

    "Where is every datetime column?" — "Which tables still use text instead of varchar(max)?" — "Are any columns using a deprecated user-defined type?" These are recurring DBA questions during schema audits, deprecation sweeps, and pre-migration assessments. This T-SQL script joins sys.columns to sys.types, sys.tables, …


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

SQLServer70.com

Your Source for SQL Server Scripts
Read More

Recent Posts

  • SQL Server DBCC Commands: The Complete DBA Reference Guide
  • SQL Server DBCC CHECKDB: Complete Guide and Repair Options
  • SQL Server DBCC FREEPROCCACHE: Clear the Plan Cache Safely
  • SQL Server DBCC SHRINKDATABASE: When and When Not to Shrink
  • SQL Server DBCC CHECKIDENT: Check and Reseed Identity
  • DBCC DBREINDEX vs ALTER INDEX REBUILD in SQL Server
  • SQL Server Duplicate and Overlapping Index Detection Script
  • SQL Server Get Table and Index Storage Size Report Script

Categories

SCRIPTS 53 SQL SERVER MAINTENANCE 11 SQL SERVER ADMINISTRATION 10 SQL SERVER MONITORING 8 SQL SERVER PERFORMANCE 8 SQL SERVER BACKUP RECOVERY 7 SQL SERVER STRUCTURE 6 SQL SERVER SECURITY 3

Series

SQL SERVER MAINTENANCE 11 SQL SERVER ADMINISTRATION 9 SQL SERVER MONITORING 8 SQL SERVER PERFORMANCE 8 SQL SERVER BACKUP RECOVERY 7 SQL SERVER STRUCTURE 6 SQL SERVER SECURITY 3 ADMIN-GUIDE 1

Tags

SQL SERVER 52 DATABASE ADMINISTRATION 39 SQL SCRIPTS 39 MAINTENANCE SCRIPTS 18 PERFORMANCE 15 DATABASE MAINTENANCE 12 SYS.TABLES 12 DBCC COMMANDS 11 SYS.DATABASES 10 SYSOBJECTS 10 DBA SCRIPTS 9 MONITORING 9 SYS.OBJECTS 9 MSDB 8
All Tags
ACTIVE SESSIONS2 ADMINISTRATION2 ALTER INDEX1 AUTOMATION2 BACKUP1 BACKUP AUDIT1 BACKUP COMPRESSION1 BACKUP MONITORING2 BACKUP RECOVERY6 BACKUP VALIDATION1 BACKUPSET1 BLOCKING2 BOTTLENECK ANALYSIS1 CAPACITY PLANNING2 CLUSTERED INDEXES1 COLUMNS1 CONSISTENCY CHECKS2 CONSTRAINT REPORTING1 CONTENTION1 COPY ONLY BACKUP1 CPU CONFIGURATION1 CPU HISTORY1 CPU UTILIZATION1 CURSOR PROGRAMMING1 DATA TYPES1 DATABASE1 DATABASE ADMINISTRATION39 DATABASE CONNECTIONS1 DATABASE CORRUPTION1 DATABASE FILES1 DATABASE INTEGRITY1 DATABASE MAINTENANCE12 DATABASE MANAGEMENT3 DATABASE MONITORING2 DATABASE OBJECTS1 DATABASE OPTIMIZATION1 DATABASE SCRIPTS1 DATABASE SECURITY1 DATABASE STRUCTURE4 DBA SCRIPTS9 DBA TOOLS1 DBCC1 DBCC CHECKDB3 DBCC CHECKIDENT2 DBCC COMMANDS11 DBCC DBINFO1 DBCC DBREINDEX2 DBCC FREEPROCCACHE1 DBCC LOGINFO1 DBCC SHRINKFILE2 DEPENDENCIES1 DEV RESTORE1 DIAGNOSTICS1 DIFFERENTIAL BACKUP1 DISK SPACE2 DM DB MISSING INDEX DETAILS1 DM DB MISSING INDEX GROUP STATS1 DM DB SESSION SPACE USAGE1 DM EXEC REQUESTS2 DM EXEC SESSIONS3 DM EXEC SQL TEXT1 DM OS WAIT STATS1 DUPLICATE INDEXES1 DYNAMIC SQL2 ERROR LOG1 EXECUTION PLAN1 FILEPROPERTY1 FOREIGN KEYS2 FRAGMENTATION2 FULL BACKUP1 GRANT STATEMENTS1 HEAP TABLES2 IDENTITY COLUMNS2 IDENTITY RESEED1 IMPACT ANALYSIS1 INDEX FRAGMENTATION2 INDEX MAINTENANCE4 INDEX OPTIMIZATION1 INDEX REBUILDING1 INDEX SIZE1 INDEX TUNING2 INDEXES4 INDEXING1 INFORMATION_SCHEMA.TABLE_CONSTRAINTS1 INFORMATION_SCHEMA.TABLES1 INTEGRITY CHECK1 JOB MONITORING1 KILL SPID1 LOG MANAGEMENT1 LOGIN MANAGEMENT1 MAINTENANCE SCRIPTS18 MAX SERVER MEMORY1 MAXDOP1 MEMORY CONFIGURATION1 METADATA1 MISSING INDEXES1 MONITORING9 MSDB8 MSDB.DBO.BACKUPMEDIAFAMILY1 MSDB.DBO.BACKUPSET1 NONCLUSTERED INDEXES1 NUMA1 OBJECT DEPENDENCIES1 OBJECT SEARCH1 OPEN TRANSACTIONS1 OPTIMIZATION2 ORPHAN USERS1 PARAMETER SNIFFING1 PERFORMANCE15 PERFORMANCE MONITORING1 PERFORMANCE TUNING7 PERMISSIONS2 PLAN CACHE2 POINT IN TIME RESTORE1 PRIMARY KEYS2 QUERY OPTIMIZATION2 QUERY PERFORMANCE1 QUERY TUNING3 REBUILD REORGANIZE1 RECOVERY1 REFACTORING1 REFERENTIAL INTEGRITY1 REPORTING3 RESTORE1 RESTORE VERIFYONLY1 RING BUFFER1 ROLE MEMBERSHIPS1 SCHEMA ANALYSIS2 SCHEMA AUDIT1 SCHEMA DOCUMENTATION1 SCHEMA MANAGEMENT1 SCRIPTS3 SECURITY3 SECURITY AUDIT2 SERVER MONITORING1 SESSION MANAGEMENT1 SP CONFIGURE1 SP_CHANGE_USERS_LOGIN1 SP_CONFIGURE2 SP_PKEYS1 SP_READERRORLOG1 SP_SPACEUSED1 SPACE MANAGEMENT1 SPACE USAGE1 SQL1 SQL SCRIPTS39 SQL SERVER52 SQL SERVER AGENT1 SQL SERVER MONITORING1 SQLSERVER PROCESS UTILIZATION1 STATISTICS1 STORAGE2 STORED PROCEDURES1 SYS.ALL_COLUMNS1 SYS.ALL_OBJECTS1 SYS.ALLOCATION_UNITS2 SYS.COLUMNS4 SYS.COMPUTED_COLUMNS1 SYS.CONFIGURATIONS1 SYS.DATABASE_FILES2 SYS.DATABASE_PERMISSIONS1 SYS.DATABASE_PRINCIPALS2 SYS.DATABASE_ROLE_MEMBERS1 SYS.DATABASES10 SYS.DM_DB_INDEX_PHYSICAL_STATS7 SYS.DM_DB_INDEX_USAGE_STATS5 SYS.DM_DB_MISSING_INDEX_DETAILS1 SYS.DM_DB_MISSING_INDEX_GROUP_STATS1 SYS.DM_DB_MISSING_INDEX_GROUPS1 SYS.DM_DB_PARTITION_STATS1 SYS.DM_EXEC_CACHED_PLANS1 SYS.DM_EXEC_QUERY_PLAN1 SYS.DM_EXEC_QUERY_STATS1 SYS.DM_EXEC_REQUESTS2 SYS.DM_EXEC_SESSIONS2 SYS.DM_EXEC_SQL_TEXT4 SYS.DM_OS_PERFORMANCE_COUNTERS1 SYS.DM_OS_RING_BUFFERS1 SYS.DM_OS_SYS_INFO1 SYS.DM_OS_VOLUME_STATS1 SYS.DM_OS_WAIT_STATS1 SYS.DM_OS_WAITING_TASKS1 SYS.DM_SQL_REFERENCED_ENTITIES1 SYS.DM_SQL_REFERENCING_ENTITIES1 SYS.DM_TRAN_ACTIVE_TRANSACTIONS1 SYS.DM_TRAN_LOCKS1 SYS.FOREIGN_KEY_COLUMNS1 SYS.FOREIGN_KEYS3 SYS.IDENTITY_COLUMNS1 SYS.INDEX_COLUMNS2 SYS.INDEXES7 SYS.KEY_CONSTRAINTS1 SYS.MASTER_FILES2 SYS.OBJECTS9 SYS.PARTITIONS3 SYS.SCHEMAS2 SYS.SERVER_PRINCIPALS1 SYS.SP_ENUMERRORLOGS1 SYS.SQL_EXPRESSION_DEPENDENCIES1 SYS.SQL_MODULES1 SYS.TABLES12 SYS.TYPES1 SYS.VIEWS1 SYSCOLUMNS1 SYSDATABASES1 SYSINDEXES2 SYSJOBHISTORY1 SYSJOBS1 SYSOBJECTS10 SYSTEM IDLE PROCESS1 SYSTEM TABLES3 T-SQL3 TABLE ANALYSIS1 TABLE MAINTENANCE1 TABLE SIZE1 TABLE STATISTICS1 TEMPDB1 TRANSACTION LOG2 TRANSACTION LOG BACKUP1 UPDATE STATISTICS1 VIEWS1 VIRTUAL LOG FILES1 WAIT STATISTICS1 WAIT TYPES3 XP_READERRORLOG1
[A~Z][0~9]
SQLServer70.com

Copyright  SQLSERVER70.COM. All Rights Reserved

to-top