The Evil That is "Select *"






4.43/5 (6 votes)
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.