Congratulations to all monthly winners of May 2013 !!! They have won INR 2900 cash and INR 27497 worth prize.
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 6798 |  Welcome, Guest!   Register  Login
 Home > Forums > Sql Server > Composite key in sql server ...
Muhsinathk

Composite key in sql server

Replies: 5 | Posted by: Muhsinathk on 6/12/2012 | Category: Sql Server Forums | Views: 645 | Status: [Member] | Points: 10  


I want to know more about composite key in sql server.
Is there any link?


Reply | Reply with attachment | Alert Moderator

 Responses below this adGet hundreds of .NET Tips and Tricks videos

 Replies

Muhsinathk
Muhsinathk  
Posted on: 6/12/2012 12:42:54 AM
Level: Bronze | Status: [Member] | Points: 25

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

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

CGN007
CGN007  
Posted on: 6/12/2012 1:02:10 AM
Level: Silver | Status: [Member] | Points: 25

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. | Reply | Alert Moderator 

CGN007
CGN007  
Posted on: 6/12/2012 1:06:07 AM
Level: Silver | Status: [Member] | Points: 25

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. | Reply | Alert Moderator 

Muhsinathk
Muhsinathk  
Posted on: 6/12/2012 1:11:02 AM
Level: Bronze | Status: [Member] | Points: 25

Thank youu

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

Sriramnandha
Sriramnandha  
Posted on: 6/21/2012 6:27:54 AM
Level: Starter | Status: [Member] | Points: 25

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. | Reply | Alert Moderator 

Reply - Please login to reply


Click here to login & reply

About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 6/18/2013 7:24:55 PM