Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2008
    Posts
    3

    Unanswered: Mistake for making a not void field empty provokes

    Hello,

    I have a table with a field that is primary key and identity autoincrementable and has also another field that cannot be void,
    On having inserted a new record (from the own(proper) Sql Server) and to make empty the field that cannot be void shows me a mistake, then I introduce the value in the above mentioned field and it turns out that the number of the field identity has increased one more number, therefore, a number has skipped.

    How can I solve this problem?

    It can only very badly that the client who uses the computer application sees hollows between the numbers.

    My problem is that if I insert a record of a table that contains a field that cannot be void and for mistake I go on to the following record gives me a mistake that warns me that such a field cannot be void, but later on having inserted the value to the above mentioned field it has put a value in the field GO that it does not correspond.

    Example
    Identifying - description - date
    1 football 01/01/2008
    empty basketball forgot me to put the date

    ON HAVING GONE ON TO THE FOLLOWING RECORD IT GIVES ME A MISTAKE, THEN I GO OUT TO THE COUNTRY AND INTRODUCE THE DATE

    3 basketball 12/12/2008

    It is to say, me the value has put 3 instead of the value 2.

    Has this solution??

    I am working with sql server 2005 express

    This happens to me when I insert a record from the Management Studio, when I select the table and say To open.

    Thank you.

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    the customer should never see the auto_incrementing number

    the solution to the gaps in the numbers is to completely ignore them

    if your application code relies on no gaps, then you are doing it wrong
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Feb 2007
    Posts
    62
    Agreed. There are numerous discussions in this area and the summary is
    a) Why? Rarely necessary
    b) If you do ever actually acheive this, your entire application will grind to a halt while every single transaction in your database waits until every other one has completed before it can assign a new ID. Your users will hate you for sure.

Posting Permissions

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