Is there a difference between Select * and Select [list each col]
database, linq, linq-to-sql, sql
Solution
Generally, it's better to be explicit, so `Select col1, col2 from Table` is better. The reason being that at some point, an extra column may be added to that table, and would cause unneeded data to be brought back from the query.
This isn't a hard and fast rule though.
Problem
I'm using MS SQL Server 2005. Is there a difference, to the SQL engine, between ``` SELECT * FROM MyTable; ``` and ``` SELECT ColA, ColB, ColC FROM MyTable; ``` When ColA, ColB, and ColC represent every column in the table? If they are the same, is there a reason why you should use the 2nd one anyway? I have a project that's heavy on LINQ, and I'm not sure if the standard SELECT * it generates is a bad practice, or if I should always be a .Select() on it to specify which cols I want. EDIT: Changed "When ColA, ColB, and ColC are all the columns to the table?" to "When ColA, ColB, and ColC represent every column in the table?" for clarity.