Results 1 to 6 of 6

Thread: SQL Server Table ... Can I have 2nd key ?

  1. #1

    Thread Starter
    Frenzied Member TheBionicOrange's Avatar
    Join Date
    Apr 2001
    Location
    Cardiff, UK
    Posts
    1,818

    Question SQL Server Table ... Can I have 2nd key ?

    I've got a SQL Server table(that I created using Enterprise Manager).

    I've not played with this much, but I want to have a secondary key on my table, and can't find an option where to do it.

    Does this mean each table can only have 1 unique key ?
    Last edited by TheBionicOrange; Aug 10th, 2004 at 09:02 AM.

  2. #2
    Frenzied Member Lightning's Avatar
    Join Date
    Oct 2002
    Location
    Eygelshoven
    Posts
    1,611
    Select 2 columns (using control) then press the "key" symbol. Now the combination of both fields ,ust be unique
    VB6 & C# (WCF LINQ) mostly


    If you need help with a WPF/WCF question post in the NEW WPF & WCF forum and we will try help the best we can

    My site

    My blog, couding troubles and solutions

    Free online tools

  3. #3

    Thread Starter
    Frenzied Member TheBionicOrange's Avatar
    Join Date
    Apr 2001
    Location
    Cardiff, UK
    Posts
    1,818
    I want a secondary key, not a composite key.

  4. #4
    Fanatic Member vb_dba's Avatar
    Join Date
    Jun 2001
    Location
    Somewhere aloft between the real world and insanity
    Posts
    1,016
    You can have only one Primary (unique) key per table, but you can add an Unique Index on the table that will force unique values per row for that column:
    Code:
    CREATE UNIQUE INDEX myIndexName
    ON myTableName (myColumnName)
    Chris

    Master Of My Domain
    Got A Question? Look Here First

  5. #5
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263
    UNIQUE constraints are implemented by an ALTERNATE INDEX on the table.

    But they force UNIQUE values in those columns.

    If you do not want that, then just CREATE alternate indexes.

    Like this:

    Code:
    CREATE INDEX AKClaim on Claim_T (MasId,FirstDate,BeneType)
    CREATE INDEX AKClaim2 on Claim_T (AdjDate,Processor,ClaimSeq)
    CREATE INDEX AKClaim3 on Claim_T (PostDate,Processor,ClaimEntry)
    CREATE INDEX AKClaim4 on Claim_T (ClaimEntry)
    CREATE INDEX AKClaim5 on Claim_T (ReversalDate)
    CREATE INDEX AKClaim6 on Claim_T (CheckNum)

  6. #6
    New Member
    Join Date
    Aug 2004
    Location
    romania
    Posts
    11
    TheBionicOrange, how have you created the SQL Server Table using Enterprise Manager? Need Help

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width