Create Constraint Primary Key


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Create Constraint Primary Key

  1. #1
    M Gunawan Guest

    Create Constraint Primary Key


    Dear All

    My application automaticaly create database and table when the first time
    application run. But i can't create multiple primary key at my table, in
    my source below i want to create WO_Number anda WO_Company as primary key.

    ....
    CnDatabase=CreateObject("ADODB.Connection")
    Cndatabase.Provider="SQLOLEDB"
    ....

    SQL="Create Table [WO_DETAIL] (" & _
    "[WO_Number] Varchar Not Null Default 'New' Primary Key," & _
    "[WO_Company] Varchar Not Null Default 'New' Primary Key)"

    Cndatabase.Execute SQL

    Statement above appear error cannot create contraint primary key ...

    Does any one know how to create multiple primary key on table

    Thank's for you help

    Gunawan


  2. #2
    Paul Mc Guest

    Re: Create Constraint Primary Key


    G'day Gunawan.

    Try this sql:
    Create Table [WO_DETAIL] (
    [WO_Number] Varchar(25) Not Null Default 'New' ,
    [WO_Company] Varchar(25) Not Null Default 'New',
    Constraint PK_WO_DETAIL Primary Key ([WO_Number],[WO_Company]))

    Note that you will need to specify the size for the varchar fields (ie (25)),
    or else the default size will be 1 I believe...


    Cheers,
    Paul


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center