Local V Global Variables

  • I have been asked to review a database and I have noticed that all the variables for the stored procedures are declared using @@, in every procedure. Looking at it I believe these should have been declared as local variables @.

    I assume this adds some extra unnecessary overhead but can't seem to find out what the implecations might be. Can any one enlighten me?

    Facts are stubborn things, but statistics are more pliable - Mark Twain
    Carolyn
    SQLServerSpecialists[/url]

  • The restriction for variables is that they start with @. They may contain @ later in their name. The extra @ does not change anything, the author may have used them to differentiate form the parameters.

    In other words, whether you start a variable name with @ or @@ the result is the same, a local variable.

    Regards,

    Andras


    Andras Belokosztolszki, MCPD, PhD
    GoldenGate Software

  • Thanks.

    Facts are stubborn things, but statistics are more pliable - Mark Twain
    Carolyn
    SQLServerSpecialists[/url]

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply