SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Failover or Restart Results in Reseed of Identity - FIX


Failover or Restart Results in Reseed of Identity - FIX

Author
Message
BinaryDigit
BinaryDigit
SSC Veteran
SSC Veteran (273 reputation)SSC Veteran (273 reputation)SSC Veteran (273 reputation)SSC Veteran (273 reputation)SSC Veteran (273 reputation)SSC Veteran (273 reputation)SSC Veteran (273 reputation)SSC Veteran (273 reputation)

Group: General Forum Members
Points: 273 Visits: 200
Comments posted to this topic are about the item Failover or Restart Results in Reseed of Identity - FIX




The Fastest Methods aren't always the Quickest Methods
telcogod
telcogod
SSC Rookie
SSC Rookie (37 reputation)SSC Rookie (37 reputation)SSC Rookie (37 reputation)SSC Rookie (37 reputation)SSC Rookie (37 reputation)SSC Rookie (37 reputation)SSC Rookie (37 reputation)SSC Rookie (37 reputation)

Group: General Forum Members
Points: 37 Visits: 561
if table was truncated before restart then the first insert after will be 0 instead of 1. This may not be desired so could you sys.identity_columns instead to get value of @max
declare @max int
select @max = isnull(convert(int,last_value),1)
FROM SYS.IDENTITY_COLUMNS
WHERE OBJECT_ID=Object_ID('t1')

DBCC CHECKIDENT([dbo.t1],RESEED,@max)

if table data was deleted @max is 0 and first insert id val will be 1
Mike Dougherty-384281
Mike Dougherty-384281
Mr or Mrs. 500
Mr or Mrs. 500 (558 reputation)Mr or Mrs. 500 (558 reputation)Mr or Mrs. 500 (558 reputation)Mr or Mrs. 500 (558 reputation)Mr or Mrs. 500 (558 reputation)Mr or Mrs. 500 (558 reputation)Mr or Mrs. 500 (558 reputation)Mr or Mrs. 500 (558 reputation)

Group: General Forum Members
Points: 558 Visits: 944
I don't understand why "holes" in the identity values should be considered a problem.

Can you provide more of the backstory as introduction to the script?
Iwas Bornready
Iwas Bornready
SSCoach
SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)

Group: General Forum Members
Points: 16376 Visits: 885
Thanks for the script.
mauriciorpp
mauriciorpp
SSC Veteran
SSC Veteran (220 reputation)SSC Veteran (220 reputation)SSC Veteran (220 reputation)SSC Veteran (220 reputation)SSC Veteran (220 reputation)SSC Veteran (220 reputation)SSC Veteran (220 reputation)SSC Veteran (220 reputation)

Group: General Forum Members
Points: 220 Visits: 259
now thats some old topic but it seems this issue is still fresh. I have just saw at the connect post that this same behaviour of identity happens on SQL 2014.

https://connect.microsoft.com/SQLServer/feedback/details/739013/alwayson-failover-results-in-reseed-of-identity

does anyone have information if this "problem" is solved in any of recent Service Packs or updates? or even if SQL2016 has it?

I really dont want to put a startup proc in all my instances... sp_FixSeeds2012 Sad
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search