Auto generated primary key

  • dilakshan31

    SSC Veteran

    Points: 276

    Ok guys, I'm a student, new to sql and really need help. How do u auto generate your primary key? I'm my case its 'event Id' note old sql. Think its 2003

  • Gail Shaw

    SSC Guru

    Points: 1004446

    No such thing as SQL 2003.

    There are many ways to generate artificial primary keys (keys that have no meaning within the data), there's also the option not to use an artificial primary keys but rather choose one of the candidate keys from the data as the primary key.

    Can you be a little clearer what you're asking?

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • dilakshan31

    SSC Veteran

    Points: 276

    Ok they have asked us to create a database which I have and now I need to create a table. They ask for event I'd to be unique and then ask for it to be auto generated

  • Lynn Pettis

    SSC Guru

    Points: 442138

    dilakshan31 (3/12/2012)


    Ok they have asked us to create a database which I have and now I need to create a table. They ask for event I'd to be unique and then ask for it to be auto generated

    Who is this "they" you are talking about?

  • Gail Shaw

    SSC Guru

    Points: 1004446

    Can you be more specific?

    What is the requirements for the EventID? What's it going to be used for? (if nothing, why do 'they' care about how it's generated)?

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • dilakshan31

    SSC Veteran

    Points: 276

    Its part of my project I have. I have no clue on how to do this

  • Gail Shaw

    SSC Guru

    Points: 1004446

    Without clearer explanations, we're not likely to have a clue either. Have you asked the teacher/lecturer?

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • dilakshan31

    SSC Veteran

    Points: 276

    That's all they ask me to do. Event I'd is an attribute in table. Which will be primary key. And now needs to be auto generated

  • Lynn Pettis

    SSC Guru

    Points: 442138

    Would still like to know who this "they" is.

    Look up identity columns in Books Online.

Viewing 9 posts - 1 through 9 (of 9 total)

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