Assign value to var in SQL 1

Assign value to var in SQL

DECLARE @EmpIDVariable int;
SELECT @EmpIDVariable = MAX(EmployeeID)
FROM HumanResources.Employee;

Here is what the above code is Doing:
1. Declaring a variable called @EmpIDVariable.
2. Assigning the value of the maximum EmployeeID in the HumanResources.Employee table to the @EmpIDVariable variable.

Similar Posts