The Bit Bucket

Shortcut: Set SQLCMD mode for all new query windows in SSMS

SQLCMD mode changes how queries are executed in SQL Server Management Studio (SSMS). When using this mode, you can work with options that aren’t normally part of SQL Server T-SQL scripts.

Some installation scripts also require SQLCMD mode and will fail if it’s not enabled.

Here’s an example of running a query against 3 servers within the same script:

First we open a new query window, then on the Query menu, we choose SQLCMD Mode.

2018-11-15

SDU Tools: List Mismatched Database Collations in SQL Server

Anyone who’s worked with SQL Server for any length of time has probably run into collation issues. They will have seen something like this:

SQL Server Error: Cannot resolve the collation conflict

In many cases, it will be a difference between the collation in tempdb and their own database, they’ve created temporary tables, and tried to join them to tables in their database. And it goes bang !

While you can fix it in the query by specifying a COLLATE clause, it’s a pain in the neck. If you use temp tables, you really should have this when working with them so your application isn’t dependent upon the server’s collation.

2018-11-14

Opinion: Corporate Compliance Isn't Training

I spend a lot of time mentoring on client sites, and many of the clients are large organizations. Often these organizations require me to attend “training” on a regular basis, to satisfy their corporate compliance goals.

I don’t mind doing this at all, even though the course on conflicts of interest, or handling private or sensitive data, at company A is invariably almost word for word the equivalent course that I do at company B, and company C.

2018-11-13

SQL: When Performance Tuning SQL Server, Fix the Problem, not the Symptom

I spend a lot of time working with teams of DBAs and developers who need to fix performance problems. One of the real issues that I see time and again though, is people fixing the symptom, not the problem.

Many DBAs spend their time tracing query activity, working out which queries the system is spending a lot of time on, and then working out how to make those important queries run faster.

2018-11-12

Basic Photo Viewer in Windows 10 - Where have you been?

I teach SQL Server, BI, Azure, and AI classes on a fairly regular basis, and one thing I love to do is to show attendees images (or photos) of where the application of the technology has gone very right or very wrong. Ever since I’d installed Windows 10 though, that became much harder.

The Photos app that’s installed with Windows 10 must have someone who loves it, but that’s not me. There seems to be no way to just have it automatically maximize the images, so I’m always showing them, then having to resize them.

2018-11-09

Shortcut: Set query shortcuts for favorite stored procedures in SSMS

In an earlier post, I mentioned how useful the F1 key is. On its own, it provides syntax help, but when you highlight an object and hit Alt-F1, you get to see metadata about the object.

Under the covers, this just runs the sp_help stored procedure. Alt-F1 has been mapped to that.

You can see where this is configured, change it if required, and/or configure other procedures as well.

In Tools, Options, Environment, Keyboard, then Query Shortcuts, you can see this:

2018-11-08

SDU Tools: List Indexes in a SQL Server Database

When I’m working with a SQL Server database, I often need a simple list of all the indexes that are already in place. I want it in a concise form. In our free SDU Tools for developers and DBAs,  we added a procedure ListIndexes to do just that, and to provide their details in a form that’s easy to consume programmatically if you need that.

You can see how to execute it in the main image above. The procedure takes these parameters:

2018-11-07

Opinion: Having staff stumble around is false economy

One thing that I see time and again on customer sites is staff who really don’t know what they’re doing in trying to solve a problem, or when they are trying to implement a new solution, yet their company just continues to pay them to stumble around while getting almost nowhere.

I’m not talking about someone who’s taking longer to achieve something than an expert. I’m talking about staff who are really out of their depth.

2018-11-06

SQL: Shrinking Files and Auto Shrink in SQL Server - Just Say No

I first started using SQL Server back in 1992 with version 4.2 I was running a software house and was hoping to use SQL Server as the back end of our updated application. 4.2 wasn’t up to it. Versions 6 and 6.5 were closer but I still thought they needed far too much administration for me to be comfortable deploying them to most customer sites. Version 7 though, changed the game. Rather than having to manage devices (which was painful), we now had just standard operating system files, and even had options for automatically growing and shrinking the files.

2018-11-05

Book Review: The Phoenix Project

I’ve been spending a lot of time lately doing DevOps related work, and I thought it was important to post a review of what is often considered the first “DevOps fictional book”. I know that sounds like a geeky book but it’s not quite as you might expect. The Phoenix Project: A Novel About IT, DevOps, and Helping Your Business Win by Gene Kim, Kevin Behr, George Spafford is a bunch of fun.

2018-11-02