• SQLKnowItAll (1/18/2013)


    The developer mentioned that since this is a declarative language, the space had to be reserved no matter where it was. That seems correct, but I don't know how to test. Thoughts?

    I would challenge the notion that because SQL is a declarative language that a T-SQL procedure follows the idea of all variables in a batch being reserved up front. If that were the case then why is that I cannot use a variable in a batch prior to when it is declared? I am thinking that while DML and DDL queries are most definitely declarative the rest is procedural, i.e. executed as lines in the batch in the order they are submitted. That said, I know what you mean, how to test it?

    My preference is aligned with both yours and Sean's. No reason to declare everything up front. I do end up moving my error variable declarations to the top of my procs sometimes though, depending on whether I have a need to do nested TRY/CATCH blocks.

    There are no special teachers of virtue, because virtue is taught by the whole community.
    --Plato