Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2004
    Location
    Alpine Califormia
    Posts
    1,789

    Unanswered: Uniqueidentifier as a primary key

    Hey can you use the Uniqueidentifier as a primary key or no??

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Yes, you can, and probably should use a UniqueIdentifier as a primary key. It might not be a good choice for a clustered index, depending on your data and what you plan to do with it.

    -PatP

  3. #3
    Join Date
    Feb 2004
    Location
    Alpine Califormia
    Posts
    1,789

    Question a Function

    HI have a Database [access 2003 as front end and SQL Server 2000 as Engine] that I have inherited and it's primary key is an autonumber [IDENTITY] and I cant stand that because it allows duplicates, is there a way that I can create my own autonumber in SQL it would be something like first part would be the year 06-0000 - 06-9999 is this possible??

    Now I was told
    "If the field is an IDENTITY and a Primary key there should not be any duplicates which is the way it is supposed to work.
    Create a function to create ot 06-0000 number and not rely on the IDENTITY field for that because it wasn't designed to be used that way."

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    IDENTITY columns do not allow duplicates

    you can use an IDENTITY column along with a prefix (like 06-) in a computed column
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  5. #5
    Join Date
    Feb 2004
    Location
    Alpine Califormia
    Posts
    1,789

    Ok Ok

    Thanks guys
    Hmm Computed column ok

Posting Permissions

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