Showing posts with label Replication. Show all posts
Showing posts with label Replication. Show all posts

Wednesday, January 5, 2011

How to set Identit Seed to all tables that have auto Increment Primarykey and seeds set to 1

In SQL Replication if we disconnect the replication between subscriber DB and publisher DB and then want to make subscriber DB as our primary Database on production server , then we face a common problem regarding the auto increment primary key because its seed set to 1 and that causes a duplicate records problem , here is the script to set seed to the maxim value.

please find the attachment for script. Click here to downlaod

Tuesday, December 28, 2010

Replication Error : the principal "dbo" does not exist, this type of principal cannot be impersonated, or you do not have permission

i was having this issue while implementing replication from SQL server 2008 to sql server 2005 . the DB on sql server 2008 was restored from another sql server 2005 server.

While Synchornizing the data with publisher data i have this error .

snapsthost is corrupted or not fully generated

so I just changed the owner of both databses on publisher server and also on subscriber server using this code
USE databsename
GO
sp_changedbowner sa -- to change DB Owner
ALTER AUTHORIZATION ON DATABASE::databsename TO sa --change the authorization schema.

How to Remove Replication from server / Cannot drop server ‘repl_distributor’ because it is used as a Distributor in replication

I was having problem to remove Replication from server after removing the replication from the db using
EXEC sp_removedbreplication 'DBName';

then after getting some research i got how to do this, here is the procedure

EXEC master.dbo.sp_serveroption @server=N'abcserver', @optname=N'dist', @optvalue=N'false'

use sp_helpserver to get servers.

or use this command
EXEC sp_dropdistributor @no_checks = 1, @ignore_distributor = 1

How to Delete "distribution" replication database

I was having a problem to delete distribution database created by replication, I was unable to remove this database even i removed all configurations related to replication.

Then after some research i got this way to delete it. First take if offline and then delete it.

USE MASTER
GO
ALTER DATABASE distribution SET OFFLINE;
DROP DATABASE distribution;

Then delete physical files .ldf and .mdf from the disk manually.