We all deserve a break don’t we? That’s what I remember being told by Ronald McDonald back when I was growing up in the 1970’s. Who’s to say that we also can’t learn something new while stepping away from the data center craziness. A couple years ago I did a few rounds of (Not) Madlibs and I’m back now for more as part of a new series of activity-related posts that give you a chance to take a break from the routine and have a bit of fun… with SQL Server! These Friday posts are your time to have a bit of fun and learn at least one new thing hopefully.
So what can you expect to learn here? You’re going to learn to use SQL Server Templates in order to do a Madlibbish style exercise. Note, these are not Mad Libs and I am making no money from this exercise. (I hope that satisfies any lawyers!)
Simply paste the downloadable code into a new query window in SQL Server Management Studio. I’ve wrapped the entire block of code in comment markers so that if you’re unwise enough to connect to a production instance of SQL you’ll not do any damage. Just in case, don’t connect to a SQL instance when doing this.
Now let the fun begin. No peeking at the code simply use the keystroke combination of Control+Shift+M and enter in values for the corresponding template parameters. Please share your completed “stories” with us here as comments!
Templates can be used to parameterize repetitive tasks. Furthermore you can save these templates for re-use and SQL even ships with many useful templates. To see these go to your Menu in SSMS, select View/Template Explorer. I leave mine up and routinely use template or create new ones that I can drag to a new query window, replace parameters, and run. You can even use the Template Explorer as a script repository – you don’t need to have parameters at all in a template if you don’t need one.