How do I make a composite key with SQL Server Management Studio?
- Open the design table tab
- Highlight your two INT fields (Ctrl/Shift+click on the grey blocks in the very first column)
- Right click -> Set primary key
here is some code to do it:
-- Sample Table
create table myTable
(
Column1 int not null,
Column2 int not null
)
GO
-- Add Constraint
ALTER TABLE myTable
ADD CONSTRAINT pk_myConstraint PRIMARY KEY (Column1,Column2)
GO
I added the constraint as a separate statement because I presume your table has already been created.