Archive | Scripts

SSRS: Parse parameters column from ExecutionLog

Ever worked on a quick little project, come across what you assume is a common need and think "I'll just google up some code that someone else has written and then be off to the races"? ┬áHave you done this and not been able to find the code you're looking for? Well, that was me […]

Parse pg_dump Functions and Views Into Their Own Files (GreenPlum / Postgres)

Here's what we wanted: Each function from our GreenPlum (aka Postgres) database scripted out into it's own file. I think after much hacking I've got something working that only requires a small amount of manual intervention. For whatever reason PostgreSQL/GreenPlum doesn't seem to have a┬ánative way to split objects into separate files. This functionality is […]

Easy SQL Server Snapshot Script / Proc

Man!!!! Why is the code to create a database snapshot so ridiculously complicated? Actually, I guess I understand why but how about allowing it to be done through SSMS and then setting a bunch of the parameters as defaults for us? Come on Microsoft! Help a SQL brother out! Well luckily, where Microsoft fails, I'm […]

SSDT – Pre and Post Deploy Script Markers And Flava Flav

I admit, this post is primarily to provide a place for me to copy and paste my own code, but it's so sweet I figured some of you other SQL Server Data Tool Users might find it handy. When troubleshooting the generated deployment scripts I've always added a PRINT statement to indicate the beginning and […]

Change The Owner Of An SSRS Subscription: The Simple Way

So you need to change the owner of an SQL Server Reporting Services subscription? No problema. (Why would you need to change it you might ask? Perhaps because you have deactivated the user account that created the subscription and now "strange things are afoot at the Circle K", and if you know that reference please […]

Add Page Compression To Every Table In Your SQL Database The Winston Wolf Way

So you need to add page level compression to every table in your SQL Server database? I'm not going to judge you. I'm not going to tell you it's a good idea or a bad idea. I needed to do it in my DEV environment and maybe you need to do it in your production […]

SQL Query To Find Expired Accounts In Active Directory: Knowledge Is Power And The Goodbye List

Alrighty. We're all data people here so you know we all agree that knowledge is power. One thing that is absolutely helpful in a large corporate environment is knowing if someone has been let go/laid off/fired. Using linked server to query active directory you can fairly easily (especially if someone else wrote the query) see […]

Get The MAX Date From A Cube Using MDX

Here's the goal: populate a sql variable with the max date from one of the dimensions in a cube. It takes a little bit of unusual code but it's relatively simple so pay attention! It's probably important to note this code is assuming you are using a smart key for your date dimension (e.g. the […]

SQL Job Steps And Run_Duration: The query that formats run_duration correctly and doesn’t make you want to shoot your eye out

Ever tried to figure out how long a step for a particular SQL Server job takes? You can of course get it from the Management Studio, but we're database people! We want to see the trend over time not just a point in time! We want to write queries! Hooray for data! You do a […]