473,473 Members | 1,960 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

SELECT *

Never say never.....

One of my applications loads a huge amount of data from a text file,
sifts through and discards much of it, and rearranges what's left.
Finally, it is added to similar data from many other files.

For that last step, SELECT * is the sensible way to go.
If you really do want everything, why force yourself to
have to edit the select if ever a column is added or deleted?

--
Wes Groleau

He that complies against his will is of the same opinion still.
-- Samuel Butler, 1612-1680
Feb 20 '07 #1
3 1701
I agree with you up to a point, but there are pitfalls.

Don't forget that if the SELECT * is in a stored procedure or a view,
the * is resolved into the columns when the procedure is CREATEd or
ALTERed. If you do not remember to re-ALTER them after a change to
the underlying table they will not reflect the current table
structure.

Roy Harvey
Beacon Falls, CT

On Tue, 20 Feb 2007 02:44:58 GMT, Wes Groleau
<gr**********@freeshell.orgwrote:
>Never say never.....

One of my applications loads a huge amount of data from a text file,
sifts through and discards much of it, and rearranges what's left.
Finally, it is added to similar data from many other files.

For that last step, SELECT * is the sensible way to go.
If you really do want everything, why force yourself to
have to edit the select if ever a column is added or deleted?
Feb 20 '07 #2
>For that last step, SELECT * is the sensible way to go. <<

No, it is lazy and dangerous, not at all sensible. Hopw hard is it to
use a text editor to get the column names? Or to write comments?
>If you really do want everything, why force yourself to have to edit the select if ever a column is added or deleted? <<
Because if you do not have control over your software, you are at the
mercy of every re-compile or change to the tables and do not know it.
And machiens have no mercy -- they will do exactly what you have told
them to do.

A good programmer writes code that protects itself.

Feb 20 '07 #3
Roy Harvey (ro********@snet.net) writes:
Don't forget that if the SELECT * is in a stored procedure or a view,
the * is resolved into the columns when the procedure is CREATEd or
ALTERed. If you do not remember to re-ALTER them after a change to
the underlying table they will not reflect the current table
structure.
True for a view, but since SQL 7 no longer for a stored procedure.

In my opinion, SELECT * from a temp table created in the same stored
procedure is OK, because you have full control. But else, it's a no-no
in my book. The database designer adds or drops a column, the result
set changes, and the client breaks. (Yes, if columns are explicitly listed,
and you drop a column, the procedure breaks. But that can be discovered
by building the database from scripts.)
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Feb 20 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: JT | last post by:
I have an input form for which I've created a "matrix" for user input. Basically, the user chooses a radio button and then through javascript, a select box is displayed to define a value for that...
4
by: Elroyskimms | last post by:
Using SQL 2000... tblCustomer: CustomerID int CompanyName varchar(20) HasRetailStores bit HasWholesaleStores bit HasOtherStores bit tblInvoiceMessages:
4
by: bobsawyer | last post by:
I've been building a series of SELECT lists that are populated dynamically using HTTPRequest. Things are going pretty well, and I've got the whole thing working flawlessly in Mozilla/Firebird....
3
by: dumbledad | last post by:
Hi All, I'm confused by how to replace a SELECT statement in a SQL statement with a specific value. The table I'm working on is a list of words (a column called "word") with an index int...
10
by: serge | last post by:
Using "SELECT * " is a bad practice even when using a VIEW instead of a table? I have some stored procedures that are identical with the difference of one statement in the WHERE clause. If I...
1
by: serena.delossantos | last post by:
Trying to insert into a history table. Some columns will come from parameters sent to the store procedure. Other columns will be filled with a separate select statement. I've tried storing the...
9
chunk1978
by: chunk1978 | last post by:
hey everyone, i've been trying to solve this problem for 2 days straight, with no end in sight. i would greatly appreciate anyone's help. EXPLANATION: There are 3 Select Menus. The 1st and...
2
by: naima.mans | last post by:
Hello, i want to select 2 following brothers nodes wich are one under another (one closed to another)... i have done one xslt file... but it's not really good.. for example: the xml file:...
4
by: rn5a | last post by:
A Form has 2 select lists. The 1st one whose size is 5 (meaning 5 options are shown at any given time) allows multiple selection whereas the 2nd one allows only 1 option to be selected at a time. ...
6
by: Apaxe | last post by:
In the database i have a table with this information: key_id =1 key_desc =43+34+22+12 I want sum the values in key_desc. Something like: SELECT key_desc FROM table But the result of...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.