Find last used SEQUENCE value in SQL Server

We usually wanted to verify the last sequence value produced by the sequences when using them, as well as the sequence’s features, such as its created date, changed date, cached, whether it is cycling, minimum value, maximum value, current value, last used value, etc.

SELECT * FROM sys.sequences WHERE name = ‘EmpSeq’;

SELECT cache_size, current_value, last_used_value FROM sys.sequences
WHERE name = ‘EmpSeq’ ;

last_used_value is the column that has the last value generated by the Next Value For function.

Please click here for more information about sequences.
For a sample of applying a sequence on a table, click here.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s