Re: Altering Identity Columns for Bidirectional Transasctional Replication
- From: InvestorTrade <shija03@xxxxxxxxx>
- Date: Tue, 20 Nov 2007 07:10:39 -0800 (PST)
Here is how I ended up doing:
- Backup the original Database containing all the data:
- Create a new database - name it backup_db
- Destroy the orginal database and recreate the database only.
- Take the scripts that created the original database (if none is
available then export the scripts from the backup_db)
- Edit the script and alter all the IDENTITY(1,1) to the desired
seed and step.
- In the original db (now empty) create only the tables - don't
worry about the views, procedures and any other objects.
- Create a snapshot replication using the backup_db as the
publishing database: ensure that the published articles are marked to
only "Delete all the data in the existing table" - this will ensure
that the subscriber's tables are not destroyed (hence keeping your new
identity definition"
- Subscribe the original db to the publication and sync it.
- Once the replication has completed we now need to update all the
tables with an identity to reseed with the latest highest value - you
can do this by defining the following script (in my case, I need the
seed to be even):
BEGIN
DECLARE @new_ident as int
SET @new_ident=(SELECT IDENT_CURRENT('your_table')) + 1
IF (@new_ident % 2) <> 0
SET @new_ident = @new_ident + 1
DBCC CHECKIDENT('ACCOUNT', RESEED, @new_ident)
END
.
- Follow-Ups:
- Re: Altering Identity Columns for Bidirectional Transasctional Replication
- From: InvestorTrade
- Re: Altering Identity Columns for Bidirectional Transasctional Replication
- References:
- Altering Identity Columns for Bidirectional Transasctional Replication
- From: InvestorTrade
- Altering Identity Columns for Bidirectional Transasctional Replication
- Prev by Date: Re: Suspect Database Issue In Production - Help Please
- Next by Date: Re: Altering Identity Columns for Bidirectional Transasctional Replication
- Previous by thread: Altering Identity Columns for Bidirectional Transasctional Replication
- Next by thread: Re: Altering Identity Columns for Bidirectional Transasctional Replication
- Index(es):
Relevant Pages
|
Loading