Script Libraries and Version Control
Raise your hand if your collection of T-SQL scripts is sitting in a folder under My Documents.
Why isn’t that script library in version control? You have version control at work, right?
Why should I version my scripts?
There’s three big reasons that you should version your scripts.
The first is to have a history of your work. Version control lets you keep track of all your changes. And, if you realize months down the road that you made a huge mistake in one of your own scripts, you can just hit undo. I’ve been able to make huge course corrections in my scripts without a lot of headache.
When you’re collaborating with team members on your scripts, version control makes it easy to sync your changes. You’re probably thinking “But a file share is much easier!” And you’d be right. A file share is incredibly easy, but a file share also means that only one person can safely modify a file at a time. Version control lets multiple people work on different parts of the same file and merge their changes together. Best of all, you can use “blame” tools in your version control to see who last worked on a specific line. I’m not saying you should be blaming your co-workers, but it does help you realize that you’re the one who broke everything.
Last, but certainly not least, it’s your legacy. Once you’ve set up version control for your scripts, your co-workers can contribute and build on what you started. By working together and collaborating, you’ll be able to make everyone’s life easier with the tools you’ve created internally.
I understand your urge to hoard secret knowledge like an alchemist of old. Remember: these are your co-workers, you’re all there for a common goal. If you don’t think that’s the case, there are problems bigger than version control.
But I don’t have version control!
You may work at a company that doesn’t have version control. While that’s weird, it’s possible. You may also not have access to version control.
The thing is, it’s really easy to get access to version control. Best of all, it’s pretty much free. I’m not going to tell you how to set up version control for yourself, but here’s a few starters:
- Github – you can create private repositories, just check the box.
- Bitbucket – you can also create private repositories here!
- Host your own git server – not as hard it sounds, but probably not for the faint of heart.
- Ask your dev team where they keep code. They’re probably happy to set you up.
You could have version control for your scripts right now!
What are you waiting for?
You should get started today! There’s no reason to put off versioning your scripts, you only have something to gain.
This is Jeremiah
I live in Portland, OR. I have two dogs.
I recently received a Master's of Science in Computer Science from Portland State University.
I'm was Microsoft MVP from 2009 - 2018 with a pile of certifications. Somewhere along the way, I wrote a database client for Riak and then handed it off to the community.