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