• GPO (7/5/2012)


    I wonder whether all SELECT * in views are created equal. That is to say equally evil. For example is a SELECT* from a preceding CTE just as bad as select * from a base table? I would have thought that selecting from the CTE was a lesser evil because everything the * is dependent on is encapsulated within the view and therefore can't be broken by a change to the underlying objects.

    Not advocating anything, merely wondering;-)

    SELECT * in the final select (that defines the result set of the view) is always wrong.

    SELECT * in subqueries or CTEs is not always bad, though I personally try to avoid it.


    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog: https://sqlserverfast.com/blog/
    SQL Server Execution Plan Reference: https://sqlserverfast.com/epr/