Results 1 to 2 of 2

Thread: solve for error

  1. #1
    Join Date
    Sep 2010
    Posts
    3

    Unanswered: solve for error

    i have an idea...

    what about if recheck the "AccNo" from form when i click submit and update ID...

    currently i using this sql command to get "AccNo" from database to the form in drop Down List...

    SELECT min(AccNo)
    FROM (SELECT AccNo + 1 AS AccNo FROM Debtor EXCEPT SELECT AccNo FROM Debtor)
    AS newAccNo WHERE AccNo >300000000

    -my AccNo start from 300000000
    -i already have data in my database more than 2000

    if i click "SAVE" button it'll check the "AccNo" in the form with databse and update automatically to new AccNo..

    Can anyone help guide how to do this...

  2. #2
    Join Date
    Nov 2004
    Posts
    1,427
    Provided Answers: 4
    Code:
    SELECT min(AccNo)
    FROM (SELECT AccNo + 1 AS AccNo 
        FROM Debtor 
            EXCEPT 
        SELECT AccNo 
        FROM Debtor) AS newAccNo 
    WHERE AccNo > 300000000
    I think you want to get the next free AccNo (lowest possible number not yet used) that is greater than 300000000. Can you rephrase/describe statement per statement your SQL query. When you do, I'm sure you will find the error in it. There is at least one more elegant way to produce it, I'll help you with that when you can correct your error.
    With kind regards . . . . . SQL Server 2000/2005/2012
    Wim

    Grabel's Law: 2 is not equal to 3 -- not even for very large values of 2.
    Pat Phelan's Law: 2 very definitely CAN equal 3 -- in at least two programming languages

Posting Permissions

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