It’s TSQL Tuesday! John Armando McCormack (blog|twitter) is our host this month and he’d like us to share some of our favorite bits of code.
Unfortunately, as a regular blogger, this is something I do all the time so I’m not sure I can come up with anything new. Over the years I’ve shared quite a few different bits of code.
- Loading the log into a temp table.
- Using that information to find out when a login was last used.
- Some security scripts: sp_SrvPermissions, sp_DBPermissions, sp_AzSQLDBPermissions, and sp_AzSynDBPermissions.
- Where is my backup?
- Database sizes
- Some fun scripts: HAL0001, HAL0002, HAL0003, and HAL0004.
- List all the jobs that ran in a given timeframe.
- When were the statistics last updated and how many rows were sampled?
- Finding the lead blocker(s).
Of course this are longer scripts and I think John meant shorter ones and I’ve done a few of those too.
- sp_spaceused
- How to create an inline table with the VALUES keyword.
- Get the code of an sp, function or view.
- sp_help functions.
- Querying sys.objects vs using “helper” functions (object_name etc).
Although he did mention talking about saving off scripts for reuse. But I’ve already talked about using solutions in SSMS to store my scripts. Heck, I even talked about creating a git repository for some of my scripts.
In the end I can’t think of anything new to write about this time around. I guess I could just do a summary post with some examples of what I’ve posted in the past? You know what. That sounds good. I’ll write a summary post.