Category | Script | ||
---|---|---|---|
Tables | Get constraints with definitions - List all constraints created in database tables including their definition. |
T-SQL
|
development, integrity, MOC20762, MOC20764 |
Tables | Query partitions with boundaries - Check what partitions are you using in the database. |
T-SQL
|
boundaries, MOC20762, MOC20764, partitioning |
Performance | AdventureWorks heavy query I - Generate heavy load over AdventureWorks database. |
T-SQL
|
AdventureWorks, MOC10987, MOC20764, query optimization, workload |
Databases | Break database consistency - This is risky! |
T-SQL
|
break database, datafiles, DBCC, issue, MOC20764 |
Security | Grant VIEW CHANGE TRACKING on tables - Generate script to grant permission quickly in more tables within database. |
T-SQL
|
change tracking, MOC20761, MOC20764, tables |
Waits | Top waits - Identify top waits occurring in SQL Server. |
T-SQL
|
MOC10987, optimization, performance, workload |
Maintenance | OH Index maintenance duration per index - Check which index's maintenance is taking most time. |
T-SQL
|
MOC20764, Ola Hallengren, optimization, performance, workload |
Configuration | Move TempDB files - Quick way to change tempdb files location. |
T-SQL
|
data movement, MOC20764, tempdb |
Configuration | Build number cut into parts - Identify build number of your SQL Server cut into parts. |
T-SQL
|
build number, MOC20764, sql server |
Execution plans | Execution count of stored procedures - Check what stored procedures are loading your SQL Server the most. |
T-SQL
|
development, MOC10987, optimization, performance, workload |
Statistics | Database statistics information - Query information about statistics in current database. |
T-SQL
|
MOC10987, optimization, performance, query estimation, query optimization, workload |
Execution plans | Plan cache distribution per database - Check what database is using most of plan cache. |
T-SQL
|
MOC10987, MOC20764, optimization, query estimation, workload |
Memory | Memory usage by memory clerks - Look under hood and check what clerks are using memory. |
T-SQL
|
MOC10987, MOC20764, performance, RAM, workload |
Memory | Memory and page file usage - Check configuration and usage of RAM and page file. |
T-SQL
|
MOC10987, MOC20764, performance, RAM, workload |
Queries | Get query completion – detailed - Retrieve information about query completion percent and estimated finish time. |
T-SQL
|
MOC20764, performance, query estimation |
Queries | Get query completion – simple - Retrieve information about query completion percent and estimated finish time. |
T-SQL
|
MOC20764, performance, query estimation |
Security | Check if login exists (SQL Server 2000) - Verify if required login exists in SQL Server 2000 instance and affect workflow. |
T-SQL
|
MOC20764 |
Security | Check if login exists - Verify if required login exists and affect workflow. |
T-SQL
|
MOC20764 |
Security | Create admin account - Simply create new account directly in WordPress database. |
MySQL
|
admin, automation, phpMyAdmin |
Memory | Buffer pool usage - Check buffer pool usage for every database. |
T-SQL
|
buffer pool, moc, MOC10987, MOC20764, RAM |
Memory | Buffer pool pages distribution - Check page count stored in buffer pool for every database. |
T-SQL
|
buffer pool, MOC10987, MOC20764, page, performance, RAM |
Execution plans | Force parameterization for query plan - Let your SQL Server know what query to parameterize if beneficial. |
T-SQL
|
MOC10987, plan guide, query estimation, query optimization |
Execution plans | Single use execution plans - Get execution plans that were used only once. |
T-SQL
|
memory bloat, MOC10987, plan cache, query optimization |
Execution plans | Get queries with same plan - Analyze plan cache for multiple use of plan by same query. |
T-SQL
|
MOC10987, query estimation, query hash, query optimization |
Databases | Shrink log for all user databases - Bulk shrink of transaction log for all databases. |
T-SQL
|
bulk, MOC20764, optimization, shrink, transaction log |
Databases | Data files latency - Examine performance of particular data files for all databases. |
T-SQL
|
disk drives, latency, MOC10987, performance |
Tables | Generate persons test data - Quickly generate some persons data using popular AdventureWorks database sample. |
T-SQL
|
AdventureWorks, cross, data, generate, join, MOC20761 |
Execution plans | Get cached execution plans - Look into your cache and see what execution plans live there. |
T-SQL
|
MOC10987, performance, query estimation, query optimization, tunning |
Security | Add database role(s) in multiple databases - Add login to same database roles in multiple databases can be time consuming. |
T-SQL
|
automation, database roles, login, MOC20764, sp_MSforeachdb |
SQL Agent | Jobs overview - Quick overview of all SQL Agent jobs. |
T-SQL
|
automation, job, maintenance, MOC20764, schedule |
Backup | Identify missing backups - Quick check if all your databases are backed up. |
T-SQL
|
backup retention, MOC20764, multiquery |
Backup | Get backup by LSN - Find backup to complete your restore operation with missing LSN. |
T-SQL
|
backup chain, LSN, MOC20764 |
Configuration | TempDB configuration check - TempDB is heavily used database in every instance, time to check it. |
T-SQL
|
CPU, datafiles, MAXDOP, MOC20764, optimization, tempdb |
Databases | Datafile auto-growth events - Looks for auto-growth events in default SQL Server trace. |
T-SQL
|
data sizing, datafiles, disk drives, MOC20764, volumes |
Databases | Set simple recovery model - Switch recovery model to SIMPLE for all databases in loop. |
T-SQL
|
MOC20764 |
AlwaysOn | Is database part of an Availability Group? - Check databases membership in Availability Groups. |
T-SQL
|
availability group, listener, MOC20764, replica |
Databases | Set Single-User mode - Set database to SINGLE_USER mode do something and set MULTI_USER mode. |
T-SQL
|
ALTER, MOC20764, multi_user, single_user |
Databases | Set Read-Only mode - Set database to read only mode do something and set read write mode. |
T-SQL
|
ALTER, MOC20764, no_wait, read-only, read-write |
Databases | Set multiple database mode - Generate script for changing mode for multiple databases. |
T-SQL
|
IMMEDIATE, MOC20764, multi-user, read-only, ROLLBACK |
Statistics | Update statistics for all databases - Easily update statistics with one line function. |
T-SQL
|
MOC10987, MOC20764, optimization, performance, resample, stats |
Indexes | Index usage - Check how are your indexes doing in the database. |
T-SQL
|
b-tree, clustered, MOC10987, MOC20764, nonclustered, scans, seeks, updates |
Indexes | Index list - Get information about all existing indexes in given database. |
T-SQL
|
index, MOC10987, MOC20764, optimization |
Databases | Collect DBCC CHECKDB results - Get more more handful information about corrupted database. |
T-SQL
|
consistency, DBCC, integrity, MOC20764, restore |
Databases | Search for value - You want to find some value within whole database, in all tables and columns? |
T-SQL
|
columns, MOC20761, search, tables |
Disk drives | Disk drives size - Returns information about space on disk drives used by databases in instance. |
T-SQL
|
disk drives, MOC20764, volumes |
Databases | Size of each database - Returns size of all databases all database files with its location and state. |
T-SQL
|
data sizing, datafiles, MOC20764 |
Databases | Size summary - Returns summary of all data within SQL Server instance grouped by type. |
T-SQL
|
data sizing, datafiles, MOC20764, tempdb |
Databases | Last schema changes - Shows information about schema changes done in databases by DDL operations. |
T-SQL
|
datafiles, DDL, MOC20764, schema changes |
Databases | Batch database drop - You need to drop more databases quickly. |
T-SQL
|
cleanup, cursor, drop database, MOC20764, remove database |
AlwaysOn | Check actual replica - You want to execute script against database only if actual database is primary replica? |
T-SQL
|
automation, availability group, MOC20764, replica, sql server |
AlwaysOn | Suspend & resume data movement - Sometimes you need to reinitialize data movement in Availability Group. |
T-SQL
|
availability group, data movement, MOC20764, sql server, synchronization |
Backup | Backup locations - Returns list of backups created over all databases, with location, timings and size information. |
T-SQL
|
backup, MOC20764, recovery, restore |
AlwaysOn | Connectivity issues - Return actual state of local replica connectivity to other replicas in Availability Group. |
T-SQL
|
availability group, connectivity, MOC20764, replica |
Motivation
So just few instructions how to use this library, it was designed to be intuitive but get this help article handy only for first use, but trust me it is nothing special to work with.
Help content
Searching
The main idea is to find script you are looking for am I right? Just use search field for whatever you look for and if you are lucky table will contain some useful scripts for your problem.
Showcase of searching using main search field
Filtering
If you want to shorten focus of scripts listed to your problem you can use advanced filtering, what you can see there depends on actual version and maybe actually there are more filtering options than in below video guide.
Showcase of using advanced filtering
TIP: You can use shortcut to filter by category when clicking category in table, only thing that happen is to use advanced filtering and filter by clicked category – so it is only shortcut 🙂
Script details
Once you will find script that should fit your search you can click its name to open modal with its details divided in tabs, copy its body or open its body in new window with raw text.
Showcase of opening script details dialog
Script body
You can use shortcut to open just script body which you can directly copy and paste where do you need. You can go to script details directly from this dialog using details link in right bottom modal footer.
Showcase of opening script body shortcut
TIP: You can use link to open script details in separate window where you can find discussion and ask some questions or provide your opinion. Click orange “Discussion” button on top right, this will bring you new browser tab with script page. On the separate script page, you can leave comments. I will see how it goes with comments and will bring them somewhere handy in the future if needed.
Script in separate tab shortcut
More ideas
If you have some idea how to make this library more efficient and user friendly I will be glad if you share your ideas with me and I will try to do my best to make it happen. Feel free to contact me if you have any questions or anything. Thank you for visiting.