Tuesday, December 18, 2012

[Solution] Add a composite primary key with Microsoft SQL Server Management Studio

A primary key of a table is not a single column, but it is a set of columns. Here is a good article about Composite Primary Keys.

How to create a composite primary key with Microsoft SQL GUI:

  1. Open Microsoft SQL Server Management Studio.
  2. Right-clickon table and select Design.
  3. Create the first primary key - right-click on the column and select Set Primary Key item.
  4. Right-click again and select Indexes/Keys...
  5. Under (General) section, click on Columns line and click button with three dots ...
  6. Add new primary key from combobox by clicking on empty line in the Column Name column.
  7. Select sort order from combobox in the Sort Order column.
  8. Click OK, Close
  9. Save changes by selecting File/Save, or pressing Ctrl+S

1 comment: