We know that if the sequence numbers in the database are used up or exhausted due to improper type setting or business explosion and other reasons, an error like the following will occur:
Msg 11728, Level 16, State 1, Line 25
The sequence object ‘SEQ_OVER_TEST’ has reached its minimum or maximum value. Restart the sequence object to allow new values to be generated.
If the DBA does not monitor the sequence, it is very likely that when the user reports / feedbacks this problem, it will find that the value of the sequence has been exhausted. At this time, the fire-fighting processing is a little hasty and awkward. Therefore, you should monitor the sequence usage of SQL server. For example, when the current value of the sequence reaches 85% of the maximum value, you should send an alarm notice. At this time, you may need to discuss the solution with the developers. The following script is used to obtain the usage of the sequence. You can use Python to collect the usage of each database sequence, and then trigger an alarm for the sequence whose current value exceeds 85% of the maximum value.