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
Ten Centuries
Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)

Group: General Forum Members
Points: 1017 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
Valued Member
Valued Member (63 reputation)Valued Member (63 reputation)Valued Member (63 reputation)Valued Member (63 reputation)Valued Member (63 reputation)Valued Member (63 reputation)Valued Member (63 reputation)Valued Member (63 reputation)

Group: General Forum Members
Points: 63 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
Ten Centuries
Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)

Group: General Forum Members
Points: 1192 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
SSC-Dedicated
SSC-Dedicated (31K reputation)SSC-Dedicated (31K reputation)SSC-Dedicated (31K reputation)SSC-Dedicated (31K reputation)SSC-Dedicated (31K reputation)SSC-Dedicated (31K reputation)SSC-Dedicated (31K reputation)SSC-Dedicated (31K reputation)

Group: General Forum Members
Points: 31802 Visits: 885
Thanks for the script.
mauriciorpp
mauriciorpp
SSC-Addicted
SSC-Addicted (470 reputation)SSC-Addicted (470 reputation)SSC-Addicted (470 reputation)SSC-Addicted (470 reputation)SSC-Addicted (470 reputation)SSC-Addicted (470 reputation)SSC-Addicted (470 reputation)SSC-Addicted (470 reputation)

Group: General Forum Members
Points: 470 Visits: 261
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