WHAT IS THE DIFFERENCE BETWEEN SET AND SELECT?

Sumit Kesarwani

Total Post:782

Points:3910
Posted by  Sumit Kesarwani
 1274  View(s)
Ratings:
Rate this:
  1. Sumit Kesarwani

    Post:782

    Points:3910
    What is the difference between SET and SELECT?

     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.

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!