''Set @local_ariable ='' vs. ''Select @local_ariable =''

  • BOL recommends that you use 'Set @local_variable = scalar_value' instead of 'Select @local_variable = scalar_value', but it doesn't say why.  Can someone tell me why 'Set' is recommended over 'Select'?

    Thank you.

    p.s.

    I don't know why the v's were removed from the title of this thread.

  • It's to do with ANSI compliance. Take a look at this article,

    http://vyaskn.tripod.com/differences_between_set_and_select.htm

     

    --------------------
    Colt 45 - the original point and click interface

  • Also, remember that 'select' always returns a count ('x rows affected') unless you use SET NOCOUNT ON.

  • I don't know the answer to this, but wouldn't there be a difference that a SET would be deterministic, while select would not?

    There may be implications regarding this (?)

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

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