Press "Enter" to skip to content

Category: Tools

Troubleshooting with sp_HumanEvents

Erik Darling shows off sp_HumanEvents:

With shorter procs you can probably just collect actual execution plans and slam F5 like a tall glass of gin at 6am.

But you don’t wanna do that with the larger procs, for a few practical reasons:

– Lots of little queries run quickly, and we don’t care about those

– Navigating through lots of plans in SSMS is tedious

– There’s no differentiation when other procedures, etc. are invoked

– You introduce a lot of overhead retrieving and rendering all those plans

– The full query text might not be captured, which is a limitation in many places

Let’s save the day with sp_HumanEvents, my stored procedure that makes using Extended Events really easy.

Read on to see how this all works.

Comments closed

Visual Studio Code, Markdown, and Snippets

Robert Cain takes us through Markdown and snippets in Visual Studio Code:

Seriously though, I do find this documentation language very useful, and easy to use. With just a few commands I can produce a nicely formatted document that can be displayed in my code editor, as well as on platforms like GitHub. I’ve even begun authoring these blog posts in Markdown.

A big reason for me is the ability to integrate it into my projects. VSCode, as well as the full blow Visual Studio, support Markdown (with of course the proper extensions installed). When I create a new PowerShell project in VSCode, I can store the projects documentation in Markdown format right alongside the PowerShell code.

By the way, two VS Code extensions I can highly recommend for their Markdown support are Markdown All in One and markdownlint.

Comments closed

SSMS Tools Pack 5.7

Mladen Prajdic announces SSMS Tools Pack 5.7.0.0:

Run script on multiple targets
Improved: Show databases that are not in normal state and are not accessible.
SQL History
Improved: Enable showing confirmation dialog when restoring the last session.
Search Results in Grid Mode
Improved: Added warning that searching through large result sets will block SSMS.

These are the improvements; click through for the list of what’s new.

Comments closed

QDS Cache Cleanup in QDS Toolbox

Jared Poche continues a series on the QDS Toolbox:

When configuring Query Store, we have a few options for deciding how it retains data but little control over how it cleans up that data. We can set the max size of our query store, the max number of plans to keep per query, and how long to keep query statistics.

The QDS Cache Cleanup component of the QDS Toolbox gives us a number of other options for what data to remove:

Read on for that list and a good example of where it was useful.

Comments closed

Azure Monitor Logs in Azure Data Studio

Julie Koesmarno has a new extension for us:

The Azure Monitor Logs extension in Azure Data Studio is now available in preview. The extension is supported in Azure Data Studio August 2021 release, v1.32.0.

Administrators can enable platform logging and metrics to one of their Azure services such as Azure SQL and set the destination to Log Analytics workspace. By installing native Azure Monitor Logs extension in Azure Data Studio, users can connect, browse, and query against Log Analytics workspace. Data professionals who are using Azure SQL, Azure PostgreSQL, or Azure Data Explorer in Azure Data Studio can access the data in the Log Analytics workspace for diagnosis or auditing in that same development environment. This native Azure Monitor Logs extension allows Azure service customers to also author notebooks with Log Analytics kernel, all equipped with Intellisense.

Click through for examples of how to use this.

Comments closed

Fixing Remote Desktop Resolution to Match Screen Size

Kenneth Fisher fixes a problem:

One of the things I hate most about using remote desktop is when the resolution for the remote server is way off what the size of my window is. You end up with the scroll bars on the side and bottom of the screen and spend half your time moving the screen around so that you can find what you need. Open Notepad, scroll to the top of the screen so you can save it, then scroll to the bottom of the screen so you can switch to the Excel spreadsheet that’s hidden by the Notepad window, etc.

It turns out there is an easy setting that forces the resolution to match the window size. Even if you end up with really weird window sizes.

My fix historically was to use mRemoteNg, which did this for you.

Comments closed

Large-Scale Database Schema Comaprison

Raul Gonzalez creates a process to compare database schemas across a large number of servers:

There are tools that can compare two databases in great detail, but the caveat I found, it is that they can only compare two databases, so while they’ll be fine to compare DEV<=>PROD or QA<=>PROD, they’re not a good fit to compare and find the differences in, literally, thousands of databases

There it’s where I was, so after some time trying to postpone the inevitable, it was time to roll up my sleeves and get the job done.

Click through for Raul’s explanation and process. At one point, I’d written something which used Red Gate’s Schema Compare DLL to do something similar. The big problem you run into is when there is no single, canonically correct database and you’re trying to generate one from the tangled mess of objects.

Comments closed

SQLCMD and the Question Mark

Solomon Rutzky stops SQLCMD in its tracks:

This is the story of one such time that I stumbled upon something interesting, and all because I made a mistake. I was doing testing for the previous post (mentioned above) and somehow entered an extra character, or forgot the closing quote on a string literal, or something. Either way, I submitted some T-SQL in the sqlcmd utility that should have produced a parsing error. But instead, it cancelled the entire query batch, and without returning any errors.

Read on to learn more and maybe have a little fun with co-workers.

Comments closed

Search and Destroy with RegEx: Visual Studio Code Edition

Andy Levy unleashes the power of regular expressions in Visual Studio Code:

Kind of a diversion into a Visual Studio Code/Azure Data Studio tip here (this works in both, as well as SQL Server Management Studio). I’m not a regular expression guru – far from it. I use them occasionally, but usually find myself fumbling around for a bit trying to figure out just the right expression to do what I need.

I’ve known for a while that VSCode/ADS had regular expression matching built into its find/replace feature, but did you know you can also replace with it? It can help remove the tedium of doing a large amount of text processing.

It’s quite a bit different from the regular expression parser in SQL Server Management Studio, but the support of capture groups in VS Code is quite helpful, as Andy demonstrates.

Comments closed