"Auto-number" in SQL .....

Results 1 to 2 of 2

Thread: "Auto-number" in SQL .....

  1. #1
    Join Date
    Dec 1969

    Default "Auto-number" in SQL .....

    I know this question has been asked before, but I just want to know if my way is the right way, or if there is a better, more efficient way.<BR><BR>I have an ID field that needs to be unique -- not necessarily sequential because I don&#039t sort on it. For the time being, I grab the number of records in the table and inc by 1.<BR><BR>I will have a minor/serious problem when I enable deleting of rows, because I might delete the first ten, causing the recordcount to -10, which will throw off all my IDs.<BR><BR>Suggestions anyone?<BR><BR>Ben

  2. #2
    Join Date
    Dec 1969

    Default RE: Identity field

    Ben,<BR><BR>If you are using SQL server, you can create an identity field. When creating a table, create a field called id, set the type to int, and uncheck the allow nulls column, and check the identity column. You should really do this for every table you create, and make this your key field. If you are going to use Access as a front end at any time, you have to have a unique field in order to add records.<BR><BR>Bill

Posting Permissions

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