Category Script
SecuritySQL Server Check if login exists (SQL Server 2000) - Verify if required login exists in SQL Server 2000 instance and affect workflow.
SecuritySQL Server Check if login exists - Verify if required login exists and affect workflow.
SecurityWordPress Create admin account - Simply create new account directly in WordPress database.
admin, automation, phpMyAdmin
MemorySQL Server Buffer pool usage - Check buffer pool usage for every database.
buffer pool, moc, MOC10987, MOC20764, RAM
MemorySQL Server Buffer pool pages distribution - Check page count stored in buffer pool for every database.
buffer pool, MOC10987, MOC20764, page, performance, RAM
Execution plansSQL Server Force parameterization for query plan - Let your SQL Server know what query to parameterize if beneficial.
MOC10987, plan guide, query estimation, query optimization
Execution plansSQL Server Single use execution plans - Get execution plans that were used only once.
memory bloat, MOC10987, plan cache, query optimization
Execution plansSQL Server Get queries with same plan - Analyze plan cache for multiple use of plan by same query.
MOC10987, query estimation, query hash, query optimization
DatabasesSQL Server Shrink log for all user databases - Bulk shrink of transaction log for all databases.
bulk, MOC20764, optimization, shrink, transaction log
DatabasesSQL Server Data files latency - Examine performance of particular data files for all databases.
disk drives, latency, MOC10987, performance
TablesSQL Server Generate persons test data - Quickly generate some persons data using popular AdventureWorks database sample.
AdventureWorks, cross, data, generate, join, MOC20761
Execution plansSQL Server Get cached execution plans - Look into your cache and see what execution plans live there.
MOC10987, performance, query estimation, query optimization, tunning
SecuritySQL Server Add database role(s) in multiple databases - Add login to same database roles in multiple databases can be time consuming.
automation, database roles, login, MOC20764, sp_MSforeachdb
SQL AgentSQL Server Jobs overview - Quick overview of all SQL Agent jobs.
automation, job, maintenance, MOC20764, schedule
BackupDisaster recovery Identify missing backups - Quick check if all your databases are backed up.
backup retention, MOC20764, multiquery
BackupDisaster recovery Get backup by LSN - Find backup to complete your restore operation with missing LSN.
backup chain, LSN, MOC20764
ConfigurationSQL Server TempDB configuration check - TempDB is heavily used database in every instance, time to check it.
CPU, datafiles, MAXDOP, MOC20764, optimization, tempdb
DatabasesSQL Server Datafile auto-growth events - Looks for auto-growth events in default SQL Server trace.
data sizing, datafiles, disk drives, MOC20764, volumes
DatabasesSQL Server Set simple recovery model - Switch recovery model to SIMPLE for all databases in loop.
AlwaysOnSQL Server Is database part of an Availability Group? - Check databases membership in Availability Groups.
availability group, listener, MOC20764, replica
DatabasesSQL Server Set Single-User mode - Set database to SINGLE_USER mode do something and set MULTI_USER mode.
ALTER, MOC20764, multi_user, single_user
DatabasesSQL Server Set Read-Only mode - Set database to read only mode do something and set read write mode.
ALTER, MOC20764, no_wait, read-only, read-write
DatabasesSQL Server Set multiple database mode - Generate script for changing mode for multiple databases.
IMMEDIATE, MOC20764, multi-user, read-only, ROLLBACK
StatisticsSQL Server Update statistics for all databases - Easily update statistics with one line function.
MOC10987, MOC20764, optimization, performance, resample, stats
IndexesSQL Server Index usage - Check how are your indexes doing in the database.
b-tree, clustered, MOC10987, MOC20764, nonclustered, scans, seeks, updates
IndexesSQL Server Index list - Get information about all existing indexes in given database.
index, MOC10987, MOC20764, optimization
DatabasesSQL Server Collect DBCC CHECKDB results - Get more more handful information about corrupted database.
consistency, DBCC, integrity, MOC20764, restore
DatabasesSQL Server Search for value - You want to find some value within whole database, in all tables and columns?
columns, MOC20761, search, tables
Disk drivesHost server Disk drives size - Returns information about space on disk drives used by databases in instance.
disk drives, MOC20764, volumes
DatabasesSQL Server Size of each database - Returns size of all databases all database files with its location and state.
data sizing, datafiles, MOC20764
DatabasesSQL Server Size summary - Returns summary of all data within SQL Server instance grouped by type.
data sizing, datafiles, MOC20764, tempdb
DatabasesSQL Server Last schema changes - Shows information about schema changes done in databases by DDL operations.
datafiles, DDL, MOC20764, schema changes
DatabasesSQL Server Batch database drop - You need to drop more databases quickly.
cleanup, cursor, drop database, MOC20764, remove database
AlwaysOnSQL Server Check actual replica - You want to execute script against database only if actual database is primary replica?
automation, availability group, MOC20764, replica, sql server
AlwaysOnSQL Server Suspend & resume data movement - Sometimes you need to reinitialize data movement in Availability Group.
availability group, data movement, MOC20764, sql server, synchronization
BackupDisaster recovery Backup locations - Returns list of backups created over all databases, with location, timings and size information.
backup, MOC20764, recovery, restore
AlwaysOnSQL Server Connectivity issues - Return actual state of local replica connectivity to other replicas in Availability Group.
availability group, connectivity, MOC20764, replica

Unfortunately nothing found

Sorry, I couldn't find any script related to your search

I can't help you with your issue now, but if you will be successfull and want to share some script which helped you, use contact channels and your script can be there filling this empty results.

Would be nice, what do you think?

There are 37 scripts published! And still growing...
Scripting library is some place, where you can find some useful script that can help you. Every script including description of results and more.  Do you like scripting? Lets check it out!


Every day I’m using some scripts to make life simpler, to avoid repeating actions or to have some fun. During the years I’ve collected many scripts (most of them are T-SQL). I kept them in OneNote document.
I was frequently asked to provide them to the colleagues, students, mates and so on. Finally I decided to make them available online. I created some kind of library with search and filtering options.
Most scripts you can find there are from internet forums or books. During the years I was not collecting all the information. Authors of the script so sorry if you find your script here without linking your page. Let me know and I will fix it immediately. Some of the script are written by me so it includes longer description or blog post.
If you want to add some your stuff, no problem. Let me know and we can help DBAs, developers, administrators or students. Everybody likes to save some time on daily routines.




If you want to be informed about new scripts published, you can subscribe to our newsletter. You will receive notifications about newly published script immediately. 

Want to recieve notification when new scripts published?

Thank you for your interest!

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


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



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 by clicking icon next to its name in modal header. 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 icon


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.