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.


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


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


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


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


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


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


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.

Share on FacebookShare on Google+Share on LinkedInTweet about this on Twitter

You may also like

  • Article

    SQL Prompt Hidden Gem: Auto-fill the GROUP BY clause

    “Have you seen this new feature that auto-fills the GROUP BY with non-aggregated columns!” exclaimed my co-worker, soon after she had installed a new version of SSMS. I hadn’t, but I was intrigued. I must have written thousands of aggregate queries in my career, so it sounded like it could save me some time. I

  • Article

    Quickly rename variables all at once with SQL Prompt

    You’re going to run into situations where someone has made poor choices in naming objects, or maybe the business logic has changed and the object name no longer makes sense. Either way, easily and quickly taking care of renaming the objects within scripts can be a pain. Let’s take this code as an example: The

  • Article

    When to use the SELECT…INTO statement (PE003)

    We can use SELECT…INTO in SQL Server to create a new table from a table source. SQL Server uses the attributes of the expressions in the SELECT list to define the structure of the new table. Prior to SQL Server 2005, use of SELECT…INTO in production code was a performance ‘code smell’ because it acquired

  • Article

    How to Test SQL Server Functions and Procedures using SQL Prompt

    When writing functions or procedures, a common chore is to devise and implement the tests that ensure that the routine always works as expected. The best way to do this is to define the tests in a batch that is attached to the CREATE or ALTER script. This isn’t just to prevent you from making

  • University

    Take the SQL Prompt course

    This Redgate University course takes you from installation all the way up to getting the most out of the advanced operations in SQL Prompt. As well as autocompleting your code, you’ll learn how SQL Prompt can help you with code formatting, object renaming, code analysis, and other useful tip and tricks.

  • Forums

    SQL Prompt Forum

    Write, format, and refactor SQL effortlessly