6 Replies - 372 Views - Last Post: 12 June 2013 - 06:52 PM Rate Topic: -----

#1 cincybengal  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 12-February 12

sql server select all records

Posted 10 June 2013 - 09:45 PM

Ok I know there's select * , and select foo,bar,..... from table, but is there another way to select all records from a table, I was told there was but these two ways are the only way i can think of.

Thanks
Is This A Good Question/Topic? 0
  • +

Replies To: sql server select all records

#2 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3352
  • View blog
  • Posts: 11,346
  • Joined: 12-December 12

Re: sql server select all records

Posted 11 June 2013 - 10:32 AM

There are the only two ways (or minor variations of them). Why would you need more? Perhaps you should explain.
Was This Post Helpful? 0
  • +
  • -

#3 DarenR  Icon User is online

  • D.I.C Lover

Reputation: 445
  • View blog
  • Posts: 3,086
  • Joined: 12-January 10

Re: sql server select all records

Posted 11 June 2013 - 10:51 AM

* is the most efficient one why would you want another one... maybe thinking of schema?
Was This Post Helpful? 0
  • +
  • -

#4 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3352
  • View blog
  • Posts: 11,346
  • Joined: 12-December 12

Re: sql server select all records

Posted 11 June 2013 - 11:09 AM

View PostDarenR, on 11 June 2013 - 05:51 PM, said:

* is the most efficient one why would you want another one... maybe thinking of schema?

* is not the most efficient - it is the least efficient. Always select just the specific fields you need unless you have a specific reason to select all fields (using *).
Was This Post Helpful? 0
  • +
  • -

#5 DarenR  Icon User is online

  • D.I.C Lover

Reputation: 445
  • View blog
  • Posts: 3,086
  • Joined: 12-January 10

Re: sql server select all records

Posted 11 June 2013 - 12:14 PM

View Postandrewsw, on 11 June 2013 - 02:09 PM, said:

View PostDarenR, on 11 June 2013 - 05:51 PM, said:

* is the most efficient one why would you want another one... maybe thinking of schema?

* is not the most efficient - it is the least efficient. Always select just the specific fields you need unless you have a specific reason to select all fields (using *).



Did he say select all records? I dont see him specifying that he only wants specific fields thus * is the most efficient.
Was This Post Helpful? 0
  • +
  • -

#6 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3352
  • View blog
  • Posts: 11,346
  • Joined: 12-December 12

Re: sql server select all records

Posted 11 June 2013 - 01:24 PM

If he wanted to select all fields then SELECT * would be easier to type than listing all the fields. As he wants all records then SELECT foo, bar is more efficient (or whatever fields he wants to retrieve).
Was This Post Helpful? 0
  • +
  • -

#7 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 574
  • View blog
  • Posts: 2,989
  • Joined: 19-May 09

Re: sql server select all records

Posted 12 June 2013 - 06:52 PM

SELECT * FROM TableName is the way to select all fields and all records. If you list fields, it's because you don't want all the fields. It is, as Andy says, more efficient to select only the fields you need if you don't need all fo them. But if you do, using * is the way to go.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1