Composite key in sql server

Posted by Muhsinathk under Sql Server on 6/12/2012 | Points: 10 | Views : 2069 | Status : [Member] | Replies : 5
I want to know more about composite key in sql server.
Is there any link?




Responses

Posted by: Muhsinathk on: 6/12/2012 [Member] Bronze | Points: 25

Up
0
Down
Composite key: One primary key Contains more then one
columns is called Composite key.

Muhsinathk, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: CGN007 on: 6/12/2012 [Member] Silver | Points: 25

Up
0
Down
The key which uniquely identify the rows of the table and is formed by combining at least two or more columns is
called composite key.
More details with example http://weblogs.sqlteam.com/jeffs/archive/2007/08/23/composite_primary_keys.aspx

Muhsinathk, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: CGN007 on: 6/12/2012 [Member] Silver | Points: 25

Up
0
Down
Syntax
-- 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


Muhsinathk, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Muhsinathk on: 6/12/2012 [Member] Bronze | Points: 25

Up
0
Down
Thank youu

Muhsinathk, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sriramnandha on: 6/21/2012 [Member] Starter | Points: 25

Up
0
Down
Hi,

More Than one Primary Key is a Composite Key.

Create table Test(Testid int,TestidKey int add constraint pk_Test(Testid,TestidKey),TestName varchar(90))

Regards

Sriram.R



sriram

Muhsinathk, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response