What to Use Select or Set to Assign the values to Variable?

  • Hi everybody,

    I am working on speed up the procedure and it has lot of calculation, i just wanted to know which keyword shall i use

    SELECT @variable = 'Value'

    OR

    SET @variable = 'Value'

    which is the fastest mode?

    Please provide some articles for further studies

    Thanks

    Patel Mohamad

  • They're the same speed.

    The advantage to Select is you can assign values to multiple variables at the same time, and can include full Select statement functionality.

    The advantage to Set is it will give you errors if you try to set multiple values to the same variable, and you can Try Catch those errors and handle them.

    But there's no speed difference.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • Agreed!!!

    You have to focus more on the joins, where clauses , sub-queries, temp tables to speed up the procedures.

    regards

    Palash Gorai

  • Thanks guys for your precious suggestion

    Patel Mohamad

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

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