Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / SQL

The Evil That is Select *

5.00/5 (4 votes)
25 Jul 2011CPOL 6.3K  
I 100% agree with this.Another trick is *if possible* add audit columns at the time of creating/designing the database, i.e.:CreatedOnCreatedByLastModifiedOnLastModifiedByThis could prevent people from using Select *, because generally we don't display such information anywhere, and...

I 100% agree with this.


Another trick is *if possible* add audit columns at the time of creating/designing the database, i.e.:


CreatedOn
CreatedBy
LastModifiedOn
LastModifiedBy

This could prevent people from using Select *, because generally we don't display such information anywhere, and also it will be useful someday to find/fix issues (or atleast you can point a finger at someone).


And for the lazy people, if you want a list of columns from a table with a lot of columns, use SQL Server Management Studio and right click on the table from Object Explorer, and "Select Top 1000 Rows", which will give you the proper Select * From table statement. Modify it and use it.

License

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