Click here to Skip to main content
12,759,636 members (35,291 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


9 bookmarked
Posted 25 Jul 2011

The Evil That is "Select *"

, 10 Aug 2011 CPOL
Rate this:
Please Sign up or sign in to vote.
Just say no to SELECT * in your SQL
There I was working on a web page, when I decided that I needed to add some new columns to an existing table. So I did. Forty-five minutes later, or system admin calls, and says a bunch of people are having problems wiht the web sight (and a related desktop app). A co-worker asked if anyone had added new columns to any of the tables, and I raised my hand.

It seems that SOMEONE had used SELECT * in one or more SQL queries into the affected table, and the act of adding a column completely hosed up the code as a result of my adding the new columns.

Nobody here really knows where the offending code is, or even if it might be in a stored procedure, but the fastest way out of the mess was to remove the columns from the existing table, and create a new table to hold them.

This is PRECISELY how spaghetti code is propagated throughout a project, along with apparently pointless tables in the database.

For the record, we don't know exactly why we're having problems because we don't have time to find out (because we wouldn't fix it if we did find out). We suspect someone wrote an INSERT or UPDATE statement that tries to do a SELECT * to move some column data around between tables. I can think of only one word to describe this, and the first syllable is "cluster".

The tip:


EDIT ================

For those of you who felt the need to tell me that the word "cluster" has two syllables - I already know that, and I have no idea where you people got the idea that I couldn't count. That particular statement is part of my endearing yet sardonic wit.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

John Simmons / outlaw programmer
Software Developer (Senior) Paddedwall Software
United States United States
I've been paid as a programmer since 1982 with experience in Pascal, and C++ (both self-taught), and began writing Windows programs in 1991 using Visual C++ and MFC. In the 2nd half of 2007, I started writing C# Windows Forms and ASP.Net applications, and have since done WPF, Silverlight, WCF, web services, and Windows services.

My weakest point is that my moments of clarity are too brief to hold a meaningful conversation that requires more than 30 seconds to complete. Thankfully, grunts of agreement are all that is required to conduct most discussions without committing to any particular belief system.

You may also be interested in...


Comments and Discussions

GeneralRe: Yes, it's kind of implied that it is "select * where (some l... Pin
BobJanova2-Aug-11 7:57
memberBobJanova2-Aug-11 7:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170217.1 | Last Updated 10 Aug 2011
Article Copyright 2011 by John Simmons / outlaw programmer
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid