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

Find out more

You may also like

  • Article

    Quick extended properties with SQL Prompt

    I’ve been experimenting with Extended Properties, and I found myself slightly annoyed by the syntax of adding and updating Extended Properties. I decided to take advantage of SQL Prompt to store the commonly used code for adding and updating properties. Adding Properties I’m a big fan of naming the snippets the first thing that comes to mind.

  • Article

    How you can improve your SQL with code analysis in SQL Prompt

    You could think of SQL Prompt code analysis as a machine-assisted code review. The rules that are used to check your code point out questionable areas that might be missed during regular testing.

  • Community event

    Raleigh Code Camp

    Redgate will be remotely sponsoring the Raleigh Code Camp 2019. Code Camp is a place for local software developers to come and learn from their peers. This community-driven event has become an international trend where peer groups of all platforms, programming languages and disciplines band together to bring content to the community.

  • Article

    SQL Prompt 10: What's New?

    Tony Davis reviews the major new features of SQL Prompt 10, included improved 'ranking' of its code auto-completion suggestions, tab history improvements to make it easier to find 'lost' code, and auto-fixing of code that breaks code analysis rules.

  • Forums

    SQL Prompt Forum

    Write, format, and refactor SQL effortlessly