Is there any significant decrease in performance, or other adverse effect by using 1-row tables instead of local variables?
instead of:
Declare @DT date = getdate()
use:
Select convert(date, getdate()) as DT into #DT
The reason I would want to do this is for code testing. When I want to run just a chunk of code, it is annoying if the code is say 100 lines down but needs several of my declarations to run.
instead of:
Line 104 select
Line 105 somecolumn
Line 106 where datadate = @DT
-- MUST DECLARE SCALAR @DT, EVEN THOUGH LINES 1-103 WERE PREVIOUSLY RUN
use:
Line 104 select
Line 105 somecolumn
Line 106 where datadate = (select DT from #DT)
-- NO ISSUE EXECUTING ONLY THESE 3 LINES, SINCE LINES 1-103 WERE PREVIOUSLY RUN
I just need to know if this is the same as far as execution time, and accuracy go. I know that the subquery will run over and over, but since #DT is one-row (and 1 column) when would things begin to lag?