download-to-storage-driveThis is the download page, where I’ve collected large scripts that aren’t practical to post in their entirety into a post, as well as other downloads. I’ve made an honest effort to test and verify them all, but bear in mind that I don’t have access to every type of advanced system setup and environment, so some of them may not work as planned on your particular server.

Read the complete disclaimer and copyright notice at the bottom of the page.

text-fileDisplay all effective permissions in a database

This script tries to compile all permissions, implicit and explicit for all user objects in a SQL Server database. Practical for security audits or general troubleshooting. Download

text-fileDecrypting SQL modules

This is the complete script as shown in the article Decrypting SQL objects. See the article for a full walk-through on what the script does. Download

text-file Display active sessions and locks

This script is useful to identify long-running or blocked queries, including which resources are locked or blocked/blocking and loads of other information about the state of your server. Download

text-file A function to calculate recurring dates

This is the fn_recurringDates() function featured in a post on creating a table value function that returns a series of dates based on a recurring pattern. Download

text-file sp_ctrl3: A replacement for sp_help

A little hack that does what sp_help does – displays information about a database object. This procedure, however shows a bit more information, and uses a more “copy-paste” friendly layout so you can script the object more easily. Add “sp_ctrl3” as a keyboard shortcut in Management Studio to quickly view the definition of any database object. Download

text-file Copying data from XML into tables

This is a script that I use to atomically insert relational data into multiple tables from a single XML blob. The XML blob can be built using the FOR XML AUTO construct. Download

text-file Synchronizing logins from another server

This stored procedure will fetch logins, user-defined server roles and memberships from another server (like an AG primary replica) and sync those to the local instance. Download

text-file Visualization of SQL Server Agent jobs

A quick hack to create a visual gantt-style bar chart of all SQL Server Agent job executions. Download

text-fileFind primary key candidates

A script that will automate the process of identifying candidates for a unique/primary key constraint on any given table. Download


General disclaimer and copyright notice

These are scripts that I’ve written and made available to you under the condition that you take responsibility for any consequences that may arise from using them. I do not recommend running them directly in production-like environments without thorough testing.


I cannot assume any responsibility regarding the accuracy of any output information, performance impacts on your server, whether the code performs correctly in your environment or any other consequences of using these downloads. It’s free, so it’s your ass. If your juristiction does not allow for this kind of waiver/disclaimer, or if you do not accept these terms, you are NOT allowed to store, distribute or use this code in any manner.


These documents are made available under the Creative Commons 4.0 (with attribution) license. In short, this allows you to freely use, modify and redistribute them without charge, though you have to quote the source (the URL of this blog,, is fine).

7 thoughts on “Downloads

  1. Howdy! None of the links for the downloads worked in my experience. I would love to take a look at them and compare to queries I currently have. Always trying to learn from the experts – Thanks!

  2. Probably the links are not allowed at John’s place of employment. Same thing happened to me when attempting to log in via my work computer.

  3. Hi Daniel,
    I’ve just tried your sp_ctrl3, very nice indeed!
    I have one suggestion, which is to add “OPTION (MAXRECURSION 0);” to the CTE for indexes.
    Without it I get the error “The maximum recursion 100 has been exhausted”, wich seems to be caused by our tables being heavily partitioned (often by day).

    • So glad you like it, and thanks for the feedback! Looks like you’ve got a pretty wide table with 100+ columns. :)
      I’ve updated the script – let me know of that works for you.

      • Wow you are quick ;-)
        Ah yes it was the columns… 114 to be exact.
        Thank you for the update!

Let me hear your thoughts!

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s