Click here to Skip to main content
13,353,124 members (70,202 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

6.2K views
1 bookmarked
Posted 25 Jul 2011

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)

Share

About the Author

Sander Rossel
Software Developer (Senior)
Netherlands Netherlands
Sander Rossel is a professional developer since 2010 with working experience in .NET (VB and C#, WinForms, MVC, Web API, and Entity Framework), SQL Server, VSTS, JavaScript, Git, Jenkins, Oracle, and other technologies.
He has an interest in various technologies including, but not limited to, functional programming, NoSQL, software design, Continuous Integration, and software quality in general.

You can't miss his must read book Continuous Integration, Delivery, and Deployment!

He also wrote the +/- 100 page eBooks Object-Oriented Programming in C# Succinctly and SQL Server for C# Developers Succinctly.

And he wrote a JavaScript LINQ library, arrgh.js (works in IE8+, Edge, Firefox, Chrome, and probably everything else).

Check out his prize-winning articles here on CodeProject as well!

You may also be interested in...

Comments and Discussions

 
GeneralThat's crazy ... almost qualifies as 'Views are evil'. Pin
BobJanova26-Jul-11 3:42
memberBobJanova26-Jul-11 3:42 
GeneralReason for my vote of 5 I've ran into this many times too. ... Pin
Steve Echols25-Jul-11 17:09
memberSteve Echols25-Jul-11 17:09 

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
Web04 | 2.8.180111.1 | Last Updated 25 Jul 2011
Article Copyright 2011 by Sander Rossel
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid