Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 8357

Re: My identity values has jumped how to set it normal

$
0
0

The easiest thing to do is probably to update the value in the rows that are reflecting the bump, then use sp_chgattribute to reset the new burning set value.

 

Start by backing up the database so that you can recover if you make a mistake.

 

Figure out the largest value used before the jump in values occurred.

Determine the smallest value generated after the jump occurred.  The difference between these two is the actual size of the gap

 

Issue the sql "set identity_update <tablename> on"

 

Then update the table setting the value of the identity column equal to itself minus the actual size of the gap.

 

Then "set identity_update <tablename> off"

 

Then determine the max value for the column and use that with

sp_changeattribute to set the identity_burn_max value for generating the next value.

 

Then, given that you don't want large gaps, configure this table (and any others where you want no large gaps) to have a small gap with

 

sp_chgattribute "table_name", "identity_gap", set_number


Viewing all articles
Browse latest Browse all 8357

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>