The IDENTITY property on a column in SQL Server allows to easily create a new number for each row added (INSERT). As a side effect, the column with the IDENTITY property also shows the natural order of records... until something is forgotten and is INSERTed at a later stage. The natural order of things is now disturbed (or has become fragmented, if you like).
CREATE TABLE OrderOfThings_1( Ident int IDENTITY(1,1) NOT NULL, OrderedSteps varchar(50) NOT NULL)GOINSERT OrderOfThings_1 (OrderedSteps) VALUES ('The first step.')INSERT OrderOfThings_1 (OrderedSteps) VALUES ('The second step.')INSERT OrderOfThings_1 (OrderedSteps) VALUES ('The fourth step.') -- Notice the forgotten third step.INSERT OrderOfThings_1 (OrderedSteps) VALUES ('The fifth step.')GOSELECT * FROM OrderOfThings_1 ORDER BY IdentGOINSERT OrderOfThings_1 (OrderedSteps) VALUES ('The third step.') -- The forgotten third step is added.GOSELECT * FROM OrderOfThings_1 ORDER BY IdentGO
Naturally we could have anticipated this scenario and set IDENTITY(10,10). But still if the thid step is to be inserted in natural order, this can only be done with significantly more effort. It requires the use of SET IDENTIY_INSERT dbo.OrderOfThings_1 ON, after which the third step can be INSERTed "in order". As the front-end application likely isn't coded for this scenario, it will require the intervention of a dba.
So it would be nice to be able to specify the natural order if needed only, and the best thing in SQL Server to just allow that is the DEFAULT. But the DEFAULT is quite limited; it can neither hold references to columns in the table nor make use of user-defined functions. So any flexibility should come from system functions, literals and operations. By using the IDENTITY property on one column and deriving the natural order from the IDENTITY with a DEFAULT based on IDENT_CURRENT, a flexible and transparent solution is available;
CREATE TABLE OrderOfThings_2( Ident int IDENTITY(1,1) NOT NULL, OrderOfSteps bigint NOT NULL CONSTRAINT df_OveridebleIdentity DEFAULT (IDENT_CURRENT('OrderOfThings_2') * 10), OrderedSteps varchar(50) NOT NULL)GOINSERT OrderOfThings_2 (OrderedSteps) VALUES ('The first step.')INSERT OrderOfThings_2 (OrderedSteps) VALUES ('The second step.')INSERT OrderOfThings_2 (OrderedSteps) VALUES ('The fourth step.') -- Notice the forgotten third step.INSERT OrderOfThings_2 (OrderedSteps) VALUES ('The fifth step.')GOSELECT * FROM OrderOfThings_2 ORDER BY IdentGOINSERT OrderOfThings_2 (OrderedSteps, OrderOfSteps) VALUES ('The third step.', 25) -- The forgotten third step is added.GOSELECT * FROM OrderOfThings_2 ORDER BY OrderOfStepsGO
Note that the OrderOfSteps column is based on bigint, which can hold any int multiplied by 10.