• I'm struggling to understand the business case where re-ordering the numbers would be desirable. So if they want to look up the printed MaintenanceOrder 105, surprise, it's actually MaintenanceOrder 102 now?

    Or are you just looking for the next available number in the sequence so you can use it when creating the next MaintenanceOrder record?

    Select Top 1 MT.MaintenanceOrder + 1 As MaintenanceOrder

    From MaintenanceTask MT

    Where Not Exists (Select Top 1 0 From MaintenanceTask MT2 Where MT2.MaintenanceOrder = (MT.MaintenanceOrder + 1))

    Order By MT.MaintenanceOrder

    If that was the case, don't. It will fail the moment any two people enter an order at the same time. Microsoft doesn't try to guarantee it with their identity columns, or with their sequence data types, and so you shouldn't try to do it either.