I have a confusion regarding defining variables in stored procedure . We can define variable in store procedure in two different ways .....


DECLARE var1

SET @var1


I am confused because ...

(a)why there are two ways to define a variable ?
(b)I'm not clear when to use DECLARE and when to use SET . Can you please explain the difference ? Is there any thumb rule when to use which variable ?