SQLServerCentral Article

SQL Prompt Tips #2 - Casing Options

,

SQL Prompt is an amazing productivity enhancement tool for SQL developers. However there are a number of features that many people are not aware of. These tips will help you learn more about ways in which SQL Prompt can speed your development. We urge you to try each of these tips out for a week or two and see if you find them helpful.

There's a link to a video demonstration of this tip as well.

Setting Case

Many of us write code in a certain case. Some of us like UPPERCASE, some lowercase, and some mixed. SQL Prompt can help you quickly format the code the way you like it, based on your preferences.

The default for SQL Prompt is UPPERCASE. This means that if I start typing code, for example, I type "sel", you'll notice that SQL Prompt shows me the match of SELECT.

I can hit "Tab" and I'll see this:

If I continue typing, and add a "*" and then an "fr", I see this.

SQL Prompt notes that my preference is to have keywords in UPPERCASE and formats things appropriately. I can continue my query and note that all of the keywords are in upper case. I have refactored my code, and notice that the datatype is also in upper case. I typed all of the code in lower case, hitting Tab where SQL Prompt had correctly shown me the rest of the word I wanted to type.

This is controlled from the Options selection under the SQL Prompt menu.

When I select this item, I get a dialog containing all of the SQL Prompt settings. I can alter the case settings by selecting the Case item on the left, under the Format group.

Notice that I have three choices on the right. There are Reserved keywords, Build-in functions, and Built-in data types. I can set any of these individually, and for each I have a few choices.

These are the common choices that many programmers might choose, and I can select any of them. As I do, I can see the sample query below, change. For example, if I select lower case for reserved words, I'll see this:

However, I can also see what my current query looks like, but selecting the tab on the lower right. If I do that, and also change my data type to UpperCamelCase, I'll see this:

The code I wrote above is shown with my formatting options selected.

I would urge you to play around with these options, and ensure your code is formatted the way that is easiest for you to work with. The case doesn't change the logic, but most of us read and grasp the meaning of well formatted code more quickly, and thus, get more work done.

Video

You can see a video demonstration of this tip below from Tom Crossman, one of Red Gate's talented employees working on SQL Prompt.

Rate

1 (1)

You rated this post out of 5. Change rating

Share

Share

Rate

1 (1)

You rated this post out of 5. Change rating