The Bit Bucket

SQL: Is AUTO_CLOSE always evil?

SQL: Is AUTO_CLOSE always evil?

I can’t tell you how many SQL Server articles that I’ve read that suggests that AUTO_CLOSE is a completely evil option. I understand the sentiment, but is that really true? If so, why does it exist in the first place?

What is the AUTO_CLOSE option?

When SQL Server is started, it normally opens all database files that are meant to be ONLINE, and it keeps them open until you shut down.

2025-06-11

SSMS Tips and Tricks 2-5: Screen and printing colors

SSMS Tips and Tricks 2-5: Screen and printing colors

SQL Server Management Studio (SSMS) is a highly configurable tool. One of the areas that’s often ignored but which can be quite important is color configuration.

SSMS color codes SQL scripts (and other types of files that it understands) as you type.

This is really useful but I’ve found on some systems that some of the color selections aren’t great. Here’s an example:

On many systems that I work with, depending upon the version, the color for sys.tables in the query above is quite a fluoro green and almost unreadable. The default from v21 onwards is much better but if you don’t like it, you can change it.

2025-06-10

SQL Interview: 54 Deadlock Correction

SQL Interview: 54 Deadlock Correction

This is a post in the SQL Interview series. These aren’t trick or gotcha questions, they’re just questions designed to scope out a candidate’s knowledge around SQL Server and Azure SQL Database.

Section: Administrtaion Level: Advanced

Question:

You have deployed a database application into production.

Soon after, you get reports that large numbers of deadlocks are occurring.

What is the most important first step in resolving deadlocks?

Answer:

While it might appear that looking into locking processes, etc. is critical, it is pointless reviewing these until you are certain that queries on the system are running efficiently.

2025-06-09

SSMS Tips and Tricks 2-4: Presentation mode

SSMS Tips and Tricks 2-4: Presentation mode

I spend a lot of time delivering presentations of various types. Many of those presentations involve showing code in either SQL Server Management Studio (SSMS) or Visual Studio (VS).

I’ve become quite fast at taking a default setup of SSMS and changing it to the fonts, etc. that I want to use for a presentation. Given how large these fonts are, I don’t want to use them for day-to-day work.

2025-06-08

General: Controlling Hugo version in Azure Static Web Apps

General: Controlling Hugo version in Azure Static Web Apps

A while back, I moved almost all of the simple websites that I work with, away from WordPress and over to Azure Static Web Apps. Overall, it has been a really good option for me.

For a start, having all my blog posts, etc. now properly in source control is wonderful. And I really enjoy being able to edit in Markdown.

For this to work though, you need a static website generator. After spending quite some time checking out YouTube videos, I opted to use Hugo as the generator. I was going to use MainRoad as the template for the site, but while it looked great, the development for it seemed to be pretty dead.

2025-06-07

SSMS Tips and Tricks 2-3: Import and Export settings

SSMS Tips and Tricks 2-3: Import and Export settings

Whenever I need to work on a new laptop or server, or whenever I change versions of SQL Server Management Studio, I kick myself for not remembering to export my settings, so I can import them again.

I spend quite a bit of effort getting SSMS configured the way I want, so it only makes sense to save the settings. Saving them isn’t perfect but it’s far better than not having done it.

2025-06-06

SQL Interview: 53 Dynamic SQL and Ownership Chaining

SQL Interview: 53 Dynamic SQL and Ownership Chaining

This is a post in the SQL Interview series. These aren’t trick or gotcha questions, they’re just questions designed to scope out a candidate’s knowledge around SQL Server and Azure SQL Database.

Section: Security Level: Advanced

Question:

You have a table named Sales.Customers that is owned by dbo. You also have a stored procedure named Sales.FindCustomers that searches the Sales.Customers table.

A user Terry is given permission to the procedure and can successfully execute the procedure.

2025-06-05

SSMS Tips and Tricks 2-2: Changing displayed status bar values

SSMS Tips and Tricks 2-2: Changing displayed status bar values

The status bar at the bottom of a query window in SQL Server Management Studio contains a wealth of information in its default configuration. The bottom left shows the connection state:

And the bottom right shows quite a bit:

In this case, it’s showing me that I’m connected to a server (local)\SQL2022; it’s running v16 of SQL Server (ie: SQL Server 2022); I’m logged on as GREG7680\Greg; my SPID (or session ID) is 88; and I’m connected to the WideWorldImporters database.

2025-06-04

Opinion: Lego and what has happened to creativity?

Opinion: Lego and what has happened to creativity?

One thing I loved doing as a child was building and creating things. With models, there were two types of projects:

  • Models with components and instructions (like Airfix)
  • Basic building materials (like Lego)

With Airfix models, the challenge was to follow the instructions to build the project, then great care required to paint and finalize the model. But there really wasn’t much creativity involved.

With basic building materials like Lego, creativity was needed to produce something that looked like (or let’s admit it often just “resembled”) whatever you were trying to build.

2025-06-03

SSMS Tips and Tricks 2-1: Environment fonts

SSMS Tips and Tricks 2-1: Environment fonts

I’ve been very lucky over the years because I haven’t needed to wear glasses. Every now and then I purchase a pair because I thought it might help with reading. Once I get them though, I find them more inconvenient than helpful and stop using them. I’ve am long-sighted in one eye and short-sighted in the other. That’s turned out to be a really useful thing in day to day life.

2025-06-02