Both SET and SELECT can be used to assign values to variables. It is recommended that SET @local_variable be used for variable assignment rather than SELECT @local_variable.
Examples
declare @i int
set @i=1
This is used to assign constant values.
select @i=max(column_name)from table_name
for ex.
select @i=max(emp_id) from table_emp.
Liked By
Write Answer
What is the difference between SET and SELECT?
Join MindStick Community
You have need login or register for voting of answers or question.
Sumit Kesarwani
15-Mar-2014Both SET and SELECT can be used to assign values to variables. It is recommended that SET @local_variable be used for variable assignment rather than SELECT @local_variable.
Examples
declare @i int
set @i=1
This is used to assign constant values.
select @i=max(column_name)from table_name
for ex.
select @i=max(emp_id) from table_emp.