Replies |
Oswaldlily
Posted on: 8/7/2012 1:57:00 AM
|
Level: Starter | Status: [Member] | Points: 25
|
Take Table page where yu ll allocate datatypes to each column name.
There right click on column name where u want to set primary key and
select "Set as Primary Key"
Parthibansk, if this helps please login to Mark As Answer. |
Reply | Alert Moderator
|
Create table tbl_CustomerProducts
(
CustomerID int not null,
ProductID int not null,
OrderLimit int not null,
Primary key (CustomerID, ProductID)
)
In the above table creation, i have used composite primary key i.e. combination of multiple columns for primary key
Parthibansk, if this helps please login to Mark As Answer. |
Reply | Alert Moderator
|
CGN007
Posted on: 8/7/2012 2:31:35 AM
|
Level: Silver | Status: [Member] | Points: 25
|
In SQL server management studio,
1. select the table design
2.Click control key(Ctrl) and select(click) the columns that you need to set primary key,and then click 'Set as primary key'
3.This creates primary key on multiple columns.
Parthibansk, if this helps please login to Mark As Answer. |
Reply | Alert Moderator
|
CREATE TABLE Persons
(
P_Id int NOT NULL,
LastName varchar(255) NOT NULL,
FirstName varchar(255),
Address varchar(255),
City varchar(255),
CONSTRAINT pk_PersonID PRIMARY KEY (P_Id,LastName)
)
Parthibansk, if this helps please login to Mark As Answer. |
Reply | Alert Moderator
|
Pandians
Posted on: 8/7/2012 5:12:56 AM
|
Level: Silver | Status: [Member] [MVP] | Points: 25
|
Check it out!
1. Add composite Primary key when creating a Table: Create Table MultiplePK
(
Id Int Identity(1,1) Not Null,
Column1 Varchar(10) Not Null,
Column2 Varchar(10), Constraint PK_Id_Column1_MultiplePK Primary Key(Id, Column1)
)
Go 2. Add composite Primary key on existing Table:
Alter Table MultiplePK Add Constraint PK_Id_Column1_MultiplePK Primary Key(Id, Column1)
Go Kindly make as Answer any one of the reply! Pls Cheers
www.SQLServerbuddy.blogspot.com
iLink Multitech Solutions
Parthibansk, if this helps please login to Mark As Answer. |
Reply | Alert Moderator
|
create table test(id int,userid int,pincode int,name varchar(90) ,primary key (int,userid,pincode))
sriram
Parthibansk, if this helps please login to Mark As Answer. |
Reply | Alert Moderator
|
Muhsinathk
Posted on: 9/4/2012 3:34:21 AM
|
Level: Bronze | Status: [Member] | Points: 25
|
CREATE TABLE table1(
ClassID int,
StudentID int,
location varchar(2),
Constraint PK_table1 PRIMARY KEY(ClassID, StudentID))
Parthibansk, if this helps please login to Mark As Answer. |
Reply | Alert Moderator
|
Pandians
Posted on: 9/4/2012 4:42:37 AM
|
Level: Silver | Status: [Member] [MVP] | Points: 25
|
Hey Parthibansk
You didn't get clarified yet ? Kindly Make any one of the reply as "ANSWER" Pls :)
Cheers
www.SQLServerbuddy.blogspot.com
iLink Multitech Solutions
Parthibansk, if this helps please login to Mark As Answer. |
Reply | Alert Moderator
|
Go through Table Level constraints Concepts
mahesh
Parthibansk, if this helps please login to Mark As Answer. |
Reply | Alert Moderator
|