How to Set Multiple Primary Keys


Multiple primary keys in a SQL Server database is called a "composite key." Many times, database developers create one primary key. This key is a unique field that helps the database server sort records and retrieve them more quickly. In some cases, you may want to use multiple fields in the table as the primary key. This can be done using the SQL Server Management Studio that is packaged with the server software.

  • Start the SQL Server Management Console. This software is usually located in the "SQL Server" directory in the Windows Start menu.

  • Click the database name on the right side of the windowpane. This expands the database objects, including the tables.

  • Right-click the table you want to edit and select "Modify." This opens the table in design view, so you can create the composite key.

  • Hold the "Ctrl" button on the keyboard and use the mouse to select each column you want to include in the composite key. After you've highlighted them all, right-click one of the columns and select "Primary Key."

  • Click the "Save" button in the SQL Server Management Console's main toolbar and close the designer.

Related Searches


Promoted By Zergnet


You May Also Like

Related Searches

Check It Out

Geek Vs Geek: Robot battles, hoverboard drag race, and more

Is DIY in your DNA? Become part of our maker community.
Submit Your Work!