Click here to Skip to main content
Click here to Skip to main content
Alternative Tip

The Evil That is "Select *"

, 25 Jul 2011
Rate this:
Please Sign up or sign in to vote.
Another 'weird feature' of select * is that in Views select * does not select all columns from a table. It selects all columns from a table that were in the table at the time that the View was created. I found that out when I added some columns to a table and wanted to map those columns in a...
Another 'weird feature' of select * is that in Views select * does not select all columns from a table. It selects all columns from a table that were in the table at the time that the View was created. I found that out when I added some columns to a table and wanted to map those columns in a custom VB Class. I created some Properties and had them filled through a SqlCommand Object which selected from a View. The Properties did not get values. I looked at the View and found select * from table along with some joins. I thought select * would always select all columns and assumed the error was in my code. Only after an hour did I update the View (simply opening the alter view script and running it did the trick, no real changes were necessary). I was amazed to see everything working after that. Getting stuff working is usually satisfying. Getting stuff working without actually changing anything is rather frustrating though...
 
That was when I renounced select *...
I only use it in ad hoc queries to look for some values, never in production code.

License

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

About the Author

Sander Rossel
Software Developer
Netherlands Netherlands
Started programming in 2010 after completing a Bachelor Common Art and Cultural Sciences and a Master Media and Journalism. A decision I haven't come to regret!
A company hired me and they taught me the basics of VB.NET, WinForms and SQL Server.
 
At the end of that year I signed up for CodeProject and that was when my programming knowledge increased rapidly. Being around some of the best and most enthausiastic coders in the world certainly helps you develop your own skills.
 
After a while I enrolled in some IT courses at the Open University and I also got Microsoft Certified.
I am currently working to get a Bachelor degree in IT.
At my job I am programming in VB.NET, C# and SQL Server using WinForms and DevExpress controls.
 
Meanwhile I am trying to educate others through my (prize-winning) articles[^] here on CodeProject.

Comments and Discussions

 
GeneralThat's crazy ... almost qualifies as 'Views are evil'. PinmemberBobJanova26-Jul-11 2:42 
GeneralReason for my vote of 5 I've ran into this many times too. ... PinmemberSteve Echols25-Jul-11 16:09 

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

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

| Advertise | Privacy | Mobile
Web02 | 2.8.140721.1 | Last Updated 25 Jul 2011
Article Copyright 2011 by Sander Rossel
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid