We use SQL Server 2008. I am building dynamic sql in code. I had new requirements that needed further filtering. It would have been pretty messy to modify the sql builder class, so, diligently following the Open Closed principle, I create a class that wrapped the sql in a CTE and then added my new where clause to it. It works great, but since my builder knows exactly the fields it needs, but my decorator class does not, I selected * from the CTE. All the reasons not to use "select *" that I have researched did not seem to apply to this situation.
The question for you sql experts, is it bad to do select * on a cte (like the following example)?
;with employeeName_cte as
(
select
FirstName
,LastName
from Employee
)
select *
from EmployeeName_cte
where
FirstName = 'bob';