I have a table variable in SQL Server 2016, as shown below.
DECLARE @Employee TABLE (EmpName VARCHAR(500), DOB DATE, AnnualSalary DECIMAL(10,2))
I need to make sure combination of EmpName and DOB is unique. Following will NOT work - it will say "Incorrect syntax".
CREATE UNIQUE INDEX IX_Temp ON @Employee (EmpName,DOB);
Since table variable doesn't allow named constraints, what is the best option to achieve this constraint?