Quick NoLock with SQL Prompt

First, please, please, please, avoid NoLock. You can lose data, or get strange results, as Jason Strate demonstrates (blog | video). Before you read further or try this, read his post and look at Kendra’s video.

I had a customer request an easy way to add NOLOCK to tables in SQL Prompt. This person wanted to be able to highlight a table and make this happen. Fortunately, this is easy in Prompt.

A snippet will allow you do this on demand. I’ll explain how.

First, open the Snippet manager from the SQL Prompt menu in SSMS.

2021-02-26 13_34_26-

Click “New” to create a new snippet.

2021-02-26 13_34_35-SQL Prompt – Options

When the form appears, fill it out as shown. Feel free to change the snippet code if you want. The $SELECTEDTEXT$ is the key. This allows me to have this snippet available when you highlight a table name.

2021-02-26 13_34_49-SQL Prompt - Edit Snippet

Save this, and then when you highlight a table, you can have Prompt add nolock by pressing CTRL and then typing your snippet name. It will be in the popup list.

I also have an animated gif to show this:

promptnolock

About way0utwest

Editor, SQLServerCentral
This entry was posted in Blog and tagged , , . Bookmark the permalink.