Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to auto-complete all columns in "select * from table" in SQL Server Management Studio

Tags:

tsql

ssms

Write this:

    Select      *         From tablea

Want this:

    Select c1, c2, c3 ... From tablea

SQL Server Management Studio provides intellisense to pick one column at a time. It takes a while for table with lots of columns.

I can use Script Table as =>Select To=> New Query Edit Window, and the copy/paste to my original script. however is there a less interruptive way?

I write SQL a lots, thanks for help!

like image 850
Rm558 Avatar asked Oct 02 '14 22:10

Rm558


2 Answers

Found this myself.

  1. Type Select * From TableA in SSMS.
  2. Exactly Select text Select * From TableA.
  3. Use Ctrl+Shift+Q to pop up Query Designer window.
  4. Click OK. "*" is replaced by "c1, c2, c3..."

Query Designer auto-populates all the columns. just open it & close. if you want only portion of columns, I found it is still easier to delete them on text editor than trying to use mouse to uncheck them on GUI.

Still hope to find a way to eliminate the Keyboard/mouse switch on step 4? seems there is no short-cut key for the OK button.

Update 2019-06-24

Above method does not work for table in SQL Azure. ApexSQL SQL formatter seems working well for me, it's free.

enter image description here

Update 2020-10-30

found a similar function in LINQPad, it allows me to auto-complete all properties in LINQ, See here

enter image description here

like image 103
Rm558 Avatar answered Nov 10 '22 06:11

Rm558


In SQL Server Management Studio if you expand the object explorer and then the node for the particular table in question then you can drag the columns node into the query window and this will type out all of the column names for you.

There are probably better ways to do this, but that's what I use.

like image 28
Paul McLoughlin Avatar answered Nov 10 '22 04:11

Paul McLoughlin