Sql-Server

SSMS Tips and Tricks 3-9: Using the clipboard ring

Two key combinations used by SQL Server T-SQL developers every day are Ctrl-C and Ctrl-V for copy and paste.

But many users of SQL Server Management Studio (SSMS) don’t realize that it has a clipboard ring and can deal with several objects in the clipboard at the same time.

Let’s see an example.

In this screen shot, I’ve opened a query window with the source code of the AnalyzeTableColumns procedure from SDU Tools.

2025-07-14

SSMS Tips and Tricks 3-8: Selecting and modifying rectangular regions

I often see people doing very repetitive editing tasks that could easily be carried out by using selecting and changing rectangular regions of code.

The simplest example of doing this is to insert some text on a number of rows. Take the following code as an example:

I’ve got the skeleton of a list of columns in a CREATE TABLE statement but let’s assume that I’m a comma in front person and want to put a few spaces and a comma, etc. in front of each column after the second.

2025-07-12

SQL Interview: 62 Selecting rows for a date

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: Development Level: Intro

Question:

You have a table of transactions. You need to select all the transactions for a particular date, based on the TransactionDateTime column. It holds datetime data type value. The date is stored in the @RequiredDate variable.

2025-07-11

SSMS Tips and Tricks 3-7: Replace tabs with spaces and do macro-like work using regular expressions

A request that I hear all the time, is “I don’t like tabs but insert name of annoying colleague here decided he likes to use them. How do I remove them?” Similar thing happens when installing SSMS and leaving the default options.

Tabs vs Spaces

Whether to use tabs or spaces leads to near religious level arguments amongst SQL developers. I see strong arguments on both sides. In the past, I’ve always ended up using spaces because I’ve run into issues with tabs in some of the tooling that I needed to use.

2025-07-10

SSMS Tips and Tricks 3-6: Manually prompting for and refreshing Intellisense

Intellisense is one of the best things that’s ever been added to Visual Studio or to SQL Server Management Studio (SSMS). It’s hard to remember back to before it was added, or how we worked then.

I had a young friend from the United Kingdom who had just completed a Computer Science degree and one of the things that he was most proud of, is that he knew so many HTML tags and which attributes went with which tags. When I showed him HTML Intellisense in Visual Studio, I think he was about to cry.

2025-07-08

SQL Interview: 61 Effects of AUTO_CLOSE

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: Administration Level: Medium

Question:

You are reviewing database settings for a server.

You notice that one database has AUTO_CLOSE configured. Your model database does not have it enabled.

What is the most likely cause for that setting to be enabled, and what effect does enabling it have?

2025-07-07

SSMS Tips and Tricks 3-5: Fixing or improving the online documentation

I mentioned in an earlier post that I think the online documentation is now superior to any version that you can install locally.

I particularly like the way that the online version is cross-version ie: each page covers all supported versions, instead of having a separate page for each version.

But one of the really big bonuses is that you also have the opportunity to change the documentation if you think it’s incorrect or you think it could be improved. Microsoft have placed all the documentation in a GitHub repository and you can change it. Doing so is easier than you might expect.

2025-07-06

SSMS Tips and Tricks 3-4: The magical F1 key - help on syntax and metadata

Years ago, I used to always recommend that people install Books Online (BOL) on their systems. It’s ironic that it was called “Online”, given we’re really talking about “Offline”, but back when we first were talking about it, we were comparing it to a physical book, not to a live reference on a computer screen.

Nowadays though, I find that the version online is so far superior to the one that you can install locally, that I think it’s better to just use the online version. I particularly like the way that the online books are now cross-version ie: each page covers all supported versions, instead of having a separate page for each version.

2025-07-04

SQL Interview: 60 Rowversion vs Timestamp

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: Development Level: Medium

Question:

You are reviewing T-SQL code from an application.

You notice in the definition of some tables, the timestamp data type has been used. In other tables, the rowversion data type has been used for similar purposes.

2025-07-03

SSMS Tips and Tricks 3-3: Apply cut or copy commands to blank lines when there is no selection

When I’m doing a lot of query editing, I often get a bit mesmerized, particularly if there’s a lot of manual copy and paste or cut and paste going on.

One thing that often drives me crazy is when I use Ctrl-C (ie: copy) when I meant to use Ctrl-V (ie: paste). Invariably, I do this when I have nothing highlighted at all. So not only did I not get the value pasted, I just copied an empty value into the clipboard.

2025-07-02