Re: Select command with multiple tables



Shwetabh (shwetabhgoel@xxxxxxxxx) writes:
But the problem is that this database has to be accessed by a third
party application which will need to access the required data using
Partnum as keyword. In such scenario, it becomes neccessary to use
select * from ... to get the row. How can I help it in such a case?

Why would have you to use SELECT *?

The problem with SELECT * is that it causes a maintenance problem.
You add a colunm, maybe in the middle. Oops, the client did handle
column numbers, and now gets confused. You remove a column, but the
query does not break. But client does.

You should never include more columns in your queries than are are
actually needed. Believe me. I work with a database that has a long
history, and since this still is very much a vital product, we change
the data model to support new features. One problem I often face is
whether a certain column can be dropped or redefined. I can make a
search in which stored procedures it is used, but often I end up in
some general procedure where data goes into the client, or even worse
are exposed in a general API. In many cases, it does not seem to make
sense, and it smells that someone added all columns while he was
at it.

Also, will it be inefficient to use select * from .. if we have to
retrieve just 1
record or is it inefficient if more records have to be retrieved?

The ineffeciency lies in the fact that you may bring bytes over the
wire that no one cares about. There is also a cost for expanding the
* into column names, but that cost is like to be negligible in many
cases.


--
Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
.



Relevant Pages

  • Re: Thinking of Access/jet to SQLServer or MySQL
    ... SQL-Server and MySQL because you will use linked tables. ... > which makes our application extremely cost effective for the client. ... > have 2 options - either MS SQL Server or MySQL for the backend. ...
    (microsoft.public.access.adp.sqlserver)
  • Thinking of Access/jet to SQLServer or MySQL
    ... SQL code), 60 forms and about 18,000 lines of code. ... application extremely cost effective for the client. ... options - either MS SQL Server or MySQL for the backend. ...
    (microsoft.public.access.adp.sqlserver)
  • Re: SQL Server 2005: Express or Developer?
    ... tools', Books Online, etc., -and an development SQL Server on the network. ... And you may wish to look at getting the Developers Edition of SQL Server. ... of the robust client and developer tools necessary for most any type of SQL ... Microsoft one and I'm building a developer's workstation software ...
    (microsoft.public.sqlserver.tools)
  • Re: Combination of English and Chinese characters in Microsoft SQLServer 2000
    ... shows as 3F for the Chinese characters. ... From a Windows client? ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ... Books Online for SQL Server 2005 at ...
    (microsoft.public.sqlserver.tools)
  • Re: SQL Union Problems When Trying to Retrieve Random Records
    ... not end up being very large and i'm not to worried about the cost of ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ... Books Online for SQL Server 2005 at ...
    (comp.databases.ms-sqlserver)

Loading