Dragging a name from the object explorer to a query window

8

May 13, 2013 by Kenneth Fisher

In the same vein as Steve Jones’ series on Customizing SSMS this is a fairly basic trick, but one that not everyone appears to know.

A fairly standard layout of SSMS looks like this.

SSMS_Drag_From_Object_Explorer

If you drill down, to say the table list, you can left-click and drag a table name from the object explorer to the query window. For long object names this can be a real life saver!

SSMS_Drag_From_Object_Explorer2

This trick will work with almost every object name in object explorer. One notable exception is the instance name. I have no idea why and I could wish that Microsoft would eliminate this exception in the future as it would have come in very handy on more than one occasion. In the mean time the ability to drag and drop the name of a Table, Column, Constraint, Index, Stored Procedure, Function, Login, or even a Job (to name just a few objects) has come in very handy time and time again.

Update

I was watching a SQL Skills insider video (if you arn’t one you should be) and was shown that you can drag the list of columns as well as individual columns. This appears to work for the groups under an individual table but not anything else.

SSMS_Drag_From_Object_Explorer3

8 thoughts on “Dragging a name from the object explorer to a query window

  1. david mckinney. says:

    You forgot to mention that you can also drag many of the actual nodes to get a comma delimited list of elements in the node. hmmm….an example would explain better.

    Drag the node ‘Columns’ (under a table or view node) and you get a comma delimited list of the column names. (Same works for indexes, keys etc. but columns is certainly the most useful I think.)

    • That certainly would have been good to mention, if I had known you could do that! Just goes to show I guess that no matter how much of an “export” you consider yourself there are plenty of “easy” things that you might have missed along the way.

      I did notice upon trying out what you suggested that it only seems to work on the lowest collections. For example it worked on columns, but not on tables. I also tried it out on parameters (within stored procedures) and it worked there too. And that would be another of the potentially more “useful” options.

      Thanks for the additional tip!

    • Thanks for the tip. This is great and needed information.

  2. Mike Segur says:

    Excellent post, thanks!

  3. […] if there are a large number of columns it’s a real pain too. (Not that you can’t just pull the column list from the object explorer.) So how do we do it without specifically listing all the columns? Well the source of this post was […]

  4. Jonathan says:

    This doesnt appear to work if the column name contains a keyword eg “Date”, “Primary” etc
    Of course you can drag the columns to Excel and add brackets – but that stops it from being a 1-click solution..

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Enter your email address to follow this blog and receive notifications of new posts by email.

Join 3,755 other subscribers

Follow me on Twitter

ToadWorld Pro of the Month November 2013
%d bloggers like this: