Our workplace has started to scan all documents rather than manually keep them in archives etc.
On average we are scanning 1,000 documents per time (this happens about 30 times per day).
Each time we scan 1,000 documents we get a small amount of errors/warnings on OCR.
Is it possible to provide the lowest and highest order numbers in to a variable and get SQL server to output a list of all missing order numbers that are not in the table between the lowest and highest order numbers?
For example
OCROrderNo
---------------
9001
9002
9006
9007
9008
9009
Lowest number 9001, highest number 9009
MissingOrderNos
--------------------
9003
9094
9005
Additional information
As per the answer, this what I am attempting:
DECLARE @Start INT = 1497389
, @End INT = 1498264
SELECT @Start + N - 1
FROM dbo.Numbers
WHERE N <= ( 1 + @End - @Start )
EXCEPT
SELECT [ORDERNUMBER]
FROM [dwdata].[dbo].[ORDERS]
ORDER BY [ORDERNUMBER] DESC
Resulting in:
Msg 207, Level 16, State 1, Line 10
Invalid column name 'ORDERNUMBER'.Msg 104, Level 16, State 1, Line 10
ORDER BY items must appear in the select list if the statement contains a UNION, INTERSECT or EXCEPT operator.
OCROrderNo
, notORDERNUMBER
. You need to adjust the sample code to your own schema, which means correcting table and column names.