Sql

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jalaludeen
    New Member
    • Apr 2007
    • 1

    #1

    Sql

    How to create composite key

    and how to set primary key for more than one column in a table
  • mcasaurabhsumit
    New Member
    • Feb 2007
    • 15

    #2
    Here customerNo will be a primary key if u write it.

    create table customers
    (
    customerNo int identity not null primary key,
    customerName varchar(30) not null,
    Address varchar(30),
    contact varchar(25),
    DateInSystem smalldatetime not null
    )

    now to make a composite key just put the primary key on two column.. When we set the constraint on two field to be primary key then it is called composite key.

    create table customers
    (
    customerNo int primary key, CustomerId int primary key,
    customerName varchar(30) not null,
    Address varchar(30),
    contact varchar(25),
    DateInSystem smalldatetime not null
    )

    Comment

    Working...