Have you ever had a need to edit multiple lines in a T-SQL script? As in, type the same text repeatedly on multiple lines? Well, a little-known key stroke makes this an easy task in Management Studio. Simply place your cursor where you want to start typing, hold down Alt+Shift and then hit either the Up or Down arrow key. You will then see a vertical blinking cursor. Now just start typing. You can even hit Enter which will add a new line in between each one where you can continue typing. Watch the video below for a quick demo.
Continue reading...Patrick Keisler
SQL Server Morning Health Checks – UPDATED!!!
A while back I wrote an article about how I created a PowerShell script for a customer to help them with their morning routine of checking the health of each SQL Server in their environment. I have not worked with that customer in a good while, but I thought it would be useful to update the script with some additional checks. The original script helps the DBA answer these questions: What is the uptime of each SQL Server? What is the status of each database? What is the status of each Availability Group? What is the backup status of each...
Continue reading...Making SQL Agent Jobs Aware of Availability Groups
What happens if you have a SQL Agent job, but the logic is not aware (or cannot be aware) that you may have an Availability Group in place. There is nothing built-in to Agent to account for this, but there is a way can you configure an Agent job to check for the existence of an AG before proceeding. Here is the scenario. First, we have a 2-node cluster running a synchronous Availability Group with automatic failover and readable secondaries turned off. Next, we have a requirement to run a SQL Agent job every hour to collect data from a...
Continue reading...Management Studio Edit Top 200 Rows
The other day I was asked why Management Studio limits you to only 200 rows when you right click on a table to edit the data. The easy answer is because that is how Management Studio is configured. However, it’s also something that can easily be changed. From the menu just select Tools and then Options. In the Options window, select SQL Server Object Explorer on the left side. On the right side you’ll see the the Table and View Options. Change the Value for Edit Top <n> Rows to something like 500 and then click OK. Now go back...
Continue reading...Management Studio Dark Theme
There is still no love for SQL Server Management Studio. SSMS v18 Beta included a Dark Theme, but somehow that did not make it into the final release of the product. Other apps have this capability (Visual Studio, Visual Studio Code, Chrome, Edge) but not SSMS. If you are like me, sometimes you want to switch your apps to a dark theme for added flair. A quick web search will reveal several ways to hack SSMS to display a dark theme, but that may not produce the best results. So, until Microsoft decides to include it, here is how I...
Continue reading...