I'm totally new to SQL Server, I use version 2012.
I have a table with the following structure:
Attendance
--------------
TagID (FK)
SessionID (FK)
ScanningTime
I need to create a unique constraint based on two columns (TagID
and SessionID
)
I'm not sure how to do this. I have created a query and tried this code:
ALTER TABLE Attendance ADD CONSTRAINT UNIQUE NONCLUSTERED
(
TagID,
SessionID
)
But when I try to execute it, I receive this error:
Msg 156, Level 15, State 1, Line 2
Incorrect syntax near the keyword 'UNIQUE'.
What is the proper way to alter the table using SSMS? Should I create a query each time I want to do so?