Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 Database Design and Application Architecture
 how to make composite primary key?

Author  Topic 

bindra.mohit88
Starting Member

4 Posts

Posted - 2009-03-25 : 08:18:39
kindly help me soon as i need to know how to make composite primary key in SQL Server 2005.
I wanna make two columns of one of my tables to combine n act as a primary key. help me out.

sunil
Constraint Violating Yak Guru

282 Posts

Posted - 2009-03-25 : 09:42:03
If you have existing table with columns CartItemId and Badge_Order , then you can use following line to make both as composite primary key.

ALTER TABLE TableName
ADD CONSTRAINT PK_TableName PRIMARY KEY (CartItemId,Badge_Order)
GO
Go to Top of Page
   

- Advertisement -