Product articles SQL Prompt SQL Code Completion and IntelliSense
Quick SQL Prompt tip – why you should…

14 September 2016
14 September 2016

Quick SQL Prompt tip – why you should expand the wildcard

One of the great things about SQL Prompt is that it quickly removes the need to use so many keystrokes. That’s helpful and handy, but to become a really efficient T-SQL coder, you’ll want to practice incorporating a few tricks into your routine.

Here’s a good one. Often I run into tables and can’t remember all the columns. One trick many people use is to type SELECT *, which gives you a quick look at a table, but isn’t what you want in production code. Instead, you’ll want to specify which fields you need to return.

When I type SELECT, I don’t get a list of columns, but a list of tables.

SQL-Prompt-1

I can pick one and then get a list of columns, but that’s slow.

SQL-Prompt-2

Instead, what I do is use the SELECT *. However, if I place the cursor after the *, I get this:

SQL-Prompt-3

If I hit TAB, I’ll then get a list of columns added to my query:

SQL-Prompt-4

Easy for this query, but for large tables and a few joins, it can be really handy. For example, look at this query:

SQL-Prompt-5b

If I expand the wildcard by typing TAB with my cursor after the *, I get this:

SQL-Prompt-6b

More fields than I need, but I can easily remove the few I don’t want and get to the actual query I need.

SQL-Prompt-7b

Using the wildcards is handy, and one of the ways you can quickly structure large queries without worrying about finding specific fields within each table.

Check out this quick video to show you SQL Prompt expanding the wildcard in action:

Or you can use one of my other SQL Prompt tips, the Column Picker. Check out this video and the rest of the #SuperSQLTips from other Data Platform MVPs and SQL Server experts. I’m sure you’ll find something really helpful for your everyday work.

Like this? Share it with other SQL professionals using the social sharing buttons below. Simply tweet: I’ve just read @way0utwest’s blog on expanding the wildcard with #SQLPrompt – see the #SuperSQLTip at rd.gt/2ctbpo9

Tools in this post

SQL Prompt

Write, format, and refactor SQL effortlessly in SQL Server Management Studio and Visual Studio.

Find out more

Share this post.

You may also like