How to make a composite key without making it a primary key in SQL Server ?
I have two int columns in a table and I want to make them as composite key, but sadly I don't want them to set as primary key (Selecting both columns and select primary key in SSMS).
Is it possible ?
What do you mean by making them composite key ?
Do you want to make them unique (in combination)?
Just create a UNIQUE CONSTRAINT on them:
ALTER TABLE dbo.YourTable
ADD CONSTRAINT UC_YourTable_Col1_Col2
UNIQUE(Col1, Col2)
Or what else do you want to achieve by making them composite key ?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With