Shortcut: Dragging all column names from Object Explorer

This is a really popular shortcut in SQL Server Management Studio (SSMS) but I continue to be amazed how many people aren't aware of it.

Object Explorer is a very useful part of SSMS and you can drag pretty much any name that you see in it, across to a query window.

You could do the same for each column in the Columns list.

You might also realize that you can hover over the asterisk and see a list of columns:

But the one that many people aren't aware of is that you can drag the word Columns across and get all the columns:

The final thing that seemed missing about this for me, was that I often wanted to do the same with the column list in a user defined table type.

I asked @sqltoolsguy and the SSMS team nicely, and only a few weeks later, that works too:

Now I just have to get them to make the quoting consistent. Notice that the table type column names aren't quoted and the table columns are 🙂

 

 

 

2 thoughts on “Shortcut: Dragging all column names from Object Explorer”

  1. There seems to be a semi-religious debate about whether SSMS should put the brackets around the names. Which approach would annoy the smallest percentage of users?

    1. My real preference would be "quote only when needed". I've previously asked for a function that determines whether or not a name needs quoting. I've also asked for a system view that returns all reserved words. Either or both of these would help. I've also asked for a QUOTENAMEIFREQUIRED function rather than just QUOTENAME. One day we might get traction on these things. The current options of quote or don't quote aren't great options.

Leave a Reply

Your email address will not be published.