Difference between DECLARE and SET in SQL
DECLARE
defines the variable type and SET
initializes the variable.
DECLARE @Var1 INT;
DECLARE @Var2 INT;
SET @Var1 = 1;
SET @Var2 = 2;
DECLARE
does not initialize the variable. When you declare it you declare the variable name, the type, and a default value, which could be an expression.
SET
is for initializing the variable you declared previously, and you cannot SET the variable until you DECLARE it.