How to declare Composite Key in a table ?

  • How to declare composite key in SQL server 2000

    I did not know how to define composite key in a table

    when we write a table with two attributes For Example

    Payment Types:  (typeId,paymentId,typeName)

     In this table “typeId” is a primary key and paymentId is a composite Key .when we define a composite key in this table then table Does not SHOW the Key with “PaymentId”

    SO Please tell me what we do for declaring the composite key in a table???

  • ALTER TABLE dbo.PaymentTypes ADD CONSTRAINT

     PK_PaymentTypes PRIMARY KEY 

     (

       typeid,

       paymentid

    )

     

  • thanks

    this work you tell me how to do  in Enterprise manager in sql server 2000

     

  • Naila,

    In Enterprise Manager, right-click on the table and select 'Design Table'. 

    Highlight the columns that you want in the primary key and click the 'set primary key' button.  Save the change and you're done.

    See 'Defining a primary key' in Books OnLine.

    Greg

     

    Greg

  • Hi Greq Charles,

    how to define Composite key in Enterprise manager?

    we set the primery key but confusion in Declaring the Composite key ?

  • A composite key is a primary key. It's a primary key made up of more than one field.

  • naila, do you mean Foreign Key? That is, paymentId is the primary key in another table.

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply