Create Table sequence_oa_merchants_enterprisebasic ( -- ID column self-increment intidentity (1,1primarykey, -- sequence value varchar(1))
CREATE FUNCTIONFn_getnextsequenceval_oa_merchants_enterprisebasic asbegin --declaring a new sequence value variable Declare @NewSeqValue int --sets the number of bars after the insert, delete operation to display cancel SetNOCOUNT on --Insert new value to Sequence_oa_merchants_enterprisebasic table Insert intoSequence_oa_merchants_enterprisebasic (Seqval)Values('a') --sets the new sequence value to the last identity value in the identity column inserted into the Sequence_oa_merchants_enterprisebasic table Set @NewSeqValue = scope_identity() --Delete sequence_oa_merchants_enterprisebasic table (does not show locked lines) Delete fromSequence_oa_merchants_enterprisebasic with(READPAST)--returns the new sequence valuereturn @NewSeqValueEnd
Declare @abc varchar (ten); exec @abc = Proc_getnextsequenceval_oa_merchants_enterprisebasic; Select Right (replicate('0',5)+@abc,5 );
Select * fromSequence_oa_merchants_enterprisebasicInsert intoSequence_oa_merchants_enterprisebasic (Seqval)Values('a')Select * fromSequence_oa_merchants_enterprisebasicDBCCCheckident ('Sequence_oa_merchants_enterprisebasic', Reseed,-1) Reset Identity
SQL Server analog sequence