I was just wondering which approach is better.
Creating a complex select query with many
CASE WHEN THEN ... ELSE ... END
statements or sub queries in select clause.Create a temp table and then insert and update it. Finally
select * from @tempTable
This question is only for complex queries not for simple joins or just when some small info has to be picked from other table.