T-SQL Tuesday this month is going back to basics and its all about code. I’d like to know “What are your go to handy short scripts”?
What are those little short bits of code that you can’t live without? I’m talking about little snippets that are only a few lines, that you may even have memorised. It could be T-SQL, PowerShell, Python or anything else you use day to day.
e.g. I manage a lot of SQL agent jobs. Quite often, I need to find out which job has a certain t-sql string in the command so I’ll run:
SELECT * from msdb..sysjobs sj JOIN msdb..sysjobsteps sjs on sj.job_id = sjs.job_id where sjs.command like 'backup log%'
Of course, there are many other ways to find this out including DBATools commands but sometime I just revert to memory for convenience.
Another one I like is to get the estimated completion rate of a backup or restore. Now there are better scripts than this but sometimes, nothing beats getting a quick estimation back from a couple of lines of memorised t-sql.
SELECT percent_complete pc,* FROM sys.dm_exec_requests order by pc desc
My invitation to you for this month’s #tsql2sday is…
I would like you to share with the community what your go to script snippets are and why you find them useful. By sharing these, you will undoubtedly be helping someone who hasn’t thought of doing it that way, and hopefully you’ll pick up some handy hints as well.
- Any language is fine, not just t-sql
- Please share as many as you wish
- Perhaps you never do this and always work off saved scripts or convert your snippets to stored procedures? Tell us why this works for you.
*** The Rules ***
- Your post must be published on Tuesday, October 12th 2021 (in any time zone).
- Include the T-SQL Tuesday Logo and make it link to this invitation post.
- Please add a comment to this post with a link to your own so I know where to find it.
- Please tweet about your post using the #tsql2sday hashtag.
Thanks for taking part
John
Rob Farley says
Thanks John. Mine’s at http://blogs.lobsterpot.com.au/2021/10/12/go-to-scripts/
kchant says
Thanks for hosting John, here’s my contribution for this month.
https://www.kevinrchant.com/2021/10/12/t-sql-tuesday-143-two-of-my-personal-go-to-scripts/
aaronbertrand says
Thanks John! Here’s my twisted entry: https://sqlblog.org/2021/10/12/t-sql-tuesday-143-worst-metadata
sqljeff says
Thanks for hosting this month! Here’s my post: https://sqladm.in/posts/tsql-tuesday-143/
-Jeff
Chad Baldwin says
Great topic! Thanks John!
https://chadbaldwin.net/2021/10/12/tsql-tuesday-short-code.html
Kenneth Fisher says
Thanks for hosting John! Great topic. Here’s my contribution.
http://sqlstudies.com/2021/10/12/code-examples-t-sql-tuesday-143/
amtwo says
Howdy John! Here’s my post on my favorite short scripts!
https://am2.co/2021/10/t-sql-tuesday-143-my-favorite-short-scripts/
brimhj says
Thanks for hosting John. Here’s my submission: https://bit.ly/3lAOMmF
Tom says
Thanks for hosting
https://straightforwardsql.com/posts/short-code-examples/
Mikey Bronowski says
Thanks for hosting John. Here is my post https://bronowski.it/t-sql-tuesday-143-short-code-examples/
Todd Kleinhans says
Thanks again for hosting John! Here is my post: https://toddkleinhans.wordpress.com/2021/10/12/t-sql-tuesday-143-import-this/
diligentdba says
https://curiousaboutdata.com/2021/10/12/tsql-tuesday-143-short-code-examples/
CallihanData says
Thanks for hosting! My post is here https://callihandata.com/2021/10/12/t-sql-tuesday-143-handy-short-scripts/
Deepthi says
Thanks so much John for hosting this month of T-SQL Tuesday!
Here is my post:
https://dbanuggets.com/2021/10/12/t-sql-tuesday-143-short-code-examples/
Koen Verbeeck #BLM 🌈 (@Ko_Ver) says
I tried to post a comment here yesterday on my mobile device, but apparently that failed 🙂 Here’s my contribution https://sqlkover.com/t-sql-tuesday-143-short-code-examples/
way0utwest says
Thanks for hosting. I’m late, but here’s my post: https://voiceofthedba.com/2021/10/13/t-sql-tuesday-143-short-code/
diligentdba says
Hi John, my contribution, for some reason it didnt appear in comments. https://curiousaboutdata.com/2021/10/12/tsql-tuesday-143-short-code-examples/
John McCormack says
Sorry if I took a while to moderate your comment, I had a few days away from the computer last week.