Displaying Source Code(s)
|
|
What is wrong with 'SELECT *'?
--------------------------------------------------------------------------------
SELECT * is inefficient, particularly when you are only using a
few of the columns in the table. This is because it
actually makes TWO queries to the database: before it runs your
query, it has to query the system tables to
determine the name and datatypes of the columns. It is much more
efficient to NAME your columns in the SQL
query, and this will also help in having your column names right
there... so you don't have to keep flipping back and
forth between ASP page and database. In addition, this will
prevent ambiguous column names in your resultset (in
the case where both are all tables in the JOIN statement have
columns with the same name).
And finally, here's another reason to avoid SELECT * : Memo/Text
columns, as well as columns containing BLOB
data. Microsoft recommends to put BLOB/text columns at the end
of the SELECT statement, in order of appearance
in the table. This is also applicable to VARCHAR columns in SQL
Server with a length greater than 255 characters.
-------------------------------------------------------------------------------- |
|
|