Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I change the default SELECT TOP 1000 query to use * instead of each field?

In SSMS 2008 R2, we have the default Select top 1000 and Edit top 200 queries from the right click menu. I've seen where you can change the # of rows it returns in the options.

What I'm after is, can I tell it to do a SELECT * instead of expanding and including every field?

It's not a performance issue or anything, just an annoyance when querying tables with more than about 5 fields, I'd like do a select *.

For example, if I have a table with the following fields:

  • FirstName
  • LastName
  • Birthday
  • City
  • State
  • Zip

When I right click on this Persons table and choose the "SELECT TOP 1000 ROWS" Menu, I'd like the query that is run to be

SELECT TOP 1000 *  FROM People

and NOT

SELECT TOP 1000 FirstName, LastName, Birthday, City, State, Zip FROM People

EDIT I suspect there isn't really an answer to this, but thought I'd see if anyone figured it out.

like image 563
taylonr Avatar asked Apr 06 '11 15:04

taylonr


1 Answers

I don't believe there is any way of customising the native SSMS functionality. However you can use the SSMS tools pack addin "Custom Scripts" for this type of thing.

Screenshot

(Though to be honest Selecting the columns and typing * might be as quick as navigating the menu)

Screenshot 2

like image 171
Martin Smith Avatar answered Sep 23 '22 07:09

Martin Smith