For me, my “can’t live without” is not a single snippet of code, but rather an entire folder of scripts, that has traveled with me from job to job over the last +10 years. Inside it, I have numerous scripts that I have written, collected, and adapted throughout my career as a DBA & DB Dev. Here’s a snapshot of my Toolbox folder!
Perusing the list, it is mostly a mix of what I categorized as Tools and Examples.
I keep Tool scripts separated out and appropriately labeled so I can jump to them quickly when needed.
Examples store various snippets of useful code, that I’ve just failed to fully memorize despite using on a regular basis. It’s frankly just easier to pop open my appropriate Examples file, copy & paste, and go on my way. I’ve considered replacing these with SSMS snippets or templates, but have usually opted not to because of having the hassle of deploying them to shared jump servers.
The other notable file is the 1_Scripts.sql file. That was my original toolbox, that contains numerous other T-SQL examples that I never bothered splitting out into individual Example files. I think of it as my most used and it contains snippets for a variety of random things.
Do you maintain a toolbox of your favorite scripts today? Well, do you ever find yourself having to re-look up the exact T-SQL syntax for something that you happen to use just often enough, but not often enough to memorize? Then give this a try!
Interested in hosting your own T-SQL Tuesday? Steve Jones has taken over, so reach out to him!