FROM (SELECT AccNo + 1 AS 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
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