Quantcast
Channel: SQL Server Replication forum
Viewing all 4054 articles
Browse latest View live

How to replicate a new table to secondary automatically.

$
0
0

We have a transactional replication  in our environment.

Frequently,  adds the new table to that source server.Can anyone advise me how to automate this process.

Requirement: When the user adds the table, it should automatically add to the snapshot and replicate to the secondary server.

Please let me know if there is any possibility to  fix the issue,



sql join query with between oepator

$
0
0

Hi,

I have 2 tables

Table1 contains Week , Week end date columns

Week    Week end date

W01     2015-01-02

W02     2015-01-09

W03     2015-01-16

Table2 contains IDdate column and date columns contains all the dates

ID     date column

01     2015-01-02

02      2015-01-03

03       2015-01-04

04       2015-01-05

05       2015-01-09

I want to select all the rows from Table2 and Week column from Table1. when I made the join condition I am getting only week end date records from Table2 . how can I select other date records?

please advice me

thanks ,


Raja

Microsoft SQL Server Replication

$
0
0

Hi,

I need information regarding the Sql Server replication. My scenario is like we are having two server machine called as Primary Server and Secondary Server. On Both the machine SQL Server is installed. And replication of Database  is done from Primary database to secondary database.

So currently it is taking some 5- 8 sec for replicating between server Primary to Secondary Server.

So want to know, once the replication is setup and both the database are in Sycn. Then if i made any changes for Primary Database, which component/ service or application will copy the changes from Primary database to secondary database and at which instance it will copy. or any scheduler is there which is copy periodically and is it possible to change the period?

Not able to configure peer to peer replication

$
0
0

Dear Team,

I have configured the peer to peer replication but the data is not replicating on subscriber and vice versa. Will you please suggest me how to check where is the issue in step by step.

I have 2 Instances On single server

1 is configured for publication and other is for Subscriber.

Step 1: Configured the distribution DB ON both the instances

Step2: Configured Publication on first node.

Step3: Right Click Publication --> Subscription Option --> Allow peer-to-peer subscriptions to True and Allow peer-to-peer conflict detection to True.

Step4: Configured Peer-to-peer topology

I did the above steps but the data is not getting replicated on subscriber. so please tell me how can itroubleshoot the issue.




How to make Transactional Replication Log Reader Agent Multi-Threaded?

$
0
0
We are facing an issue where log reader consumes one CPU on the server to 100% while other CPUs are not even 5% utilized. Replication falls behind due to this reason. Is it possible to make log reader agent multi-threaded so it can use multiple CPUs?

Rename a column in a replicated table

$
0
0
Hi, I tried to run this(below) the table is replicated(transactional).

EXECUTE

 

sp_renameN'dbo.Tablename.Columnname,N'New_Columnname','COLUMN'

But getting this error message:

Msg 15051, Level 11, State 1, Procedure sp_rename, Line 227

Cannot rename the table because it is published for replication.

 

Thank You

Powershell not scripting all options specified for replication

$
0
0

Hi all,

So I started writing a script, borrowing form two others people have posted, and it works pretty well. Meaning it almost completely matches the output I would get from scripting the replication out from SQL Server itself. However, there are a couple of things that are not showing up in the script, and I am curious if anyone knows why? The script is attached. The pieces I am curious about are:

Adding the option to IncludeUninstallDistributor or UninstallDistributor doesn't appear to add any code to actually do that. i.e. the below code is never added.

/****** Uninstalling the server as a Distributor. Script Date: 10/1/2015 4:34:13 PM ******/
use master
exec sp_dropdistributor @no_checks = 1, @ignore_distributor = 1
GO

Also, adding the reverse for the create script generation, IncludeInstallDistributor or InstallDistributor, does not add the below code.

use master
exec sp_adddistributor @distributor = N'xxx\xxx', @password = N''
GO

The purpose of the script is simply to script out all drop/create scripts for all publications and subscriptions, run the drop script, restore over the databases using backups of non-replicated databases, run the create replication script, and have it re-sync.

This is as far as I have gotten. Thoughts?

param ([string] $Publisher ,
       [string] $OutputFile = "C:\Temp\Repl-Backup.sql")

    [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.Replication") | out-null
    [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.RMO") | out-null

    [string] $Output = ""
    [int] $TranPubCnt = 0
    [int] $MergePubCnt = 0

    if ($Publisher -eq "" -or $Publisher -eq [string]::Empty)
    {
        $Publisher = read-host -prompt "Publisher?"
    }

    if (Test-Path $OutputFile)
    {
        Clear-Content $OutputFile
    }

    $ReplSvr = New-Object ("Microsoft.SqlServer.Replication.ReplicationServer") $Publisher"" > $OutputFile

    if ($ReplSvr.ReplicationDatabases.Count -eq 0)
    {
        $Output = "No replicated databases found for Publisher " + $Publisher
        $Output >> $OutputFile

        #return
    }

    foreach($Database in $ReplSvr.ReplicationDatabases)
    {
        $TranPubCnt = $TranPubCnt + $Database.TransPublications.Count
        $MergePubCnt = $MergePubCnt + $Database.MergePublications.Count
    }

    if (($TranPubCnt + $MergePubCnt) -eq 0)
    {
        $Output = "No Publications found for Publisher " + $Publisher
        $Output >> $OutputFile

        #return
    }

    # Drop

#    $ScriptOptions = [Microsoft.SqlServer.Replication.scriptoptions]::Deletion `
 #              -bor  [Microsoft.SqlServer.Replication.scriptoptions]::IncludeSubscriberSideSubscriptions `
  #             -bor  [Microsoft.SqlServer.Replication.scriptoptions]::IncludeArticles `
   #            -bor  [Microsoft.SqlServer.Replication.scriptoptions]::IncludePublisherSideSubscriptions `
    #           -bor  [Microsoft.SqlServer.Replication.scriptoptions]::IncludeDisableReplicationDB `
     #          -bor  [Microsoft.SqlServer.Replication.scriptoptions]::IncludePublicationAccesses `
      #         -bor  [Microsoft.SqlServer.Replication.scriptoptions]::IncludeGo `

    # Create
    $ScriptOptions = [Microsoft.SqlServer.Replication.ScriptOptions]::Creation `
               -bor  [Microsoft.SqlServer.Replication.scriptoptions]::IncludeInstallDistributor `
               -bor  [Microsoft.SqlServer.Replication.scriptoptions]::EnableReplicationDB `
               -bor  [Microsoft.SqlServer.Replication.scriptoptions]::IncludePublisherSideSubscriptions `
               -bor  [Microsoft.SqlServer.Replication.scriptoptions]::IncludeCreateLogreaderAgent `
               -bor  [Microsoft.SqlServer.Replication.scriptoptions]::IncludeCreateDistributionAgent `
               -bor  [Microsoft.SqlServer.Replication.scriptoptions]::IncludeCreateMergeAgent `
               -bor  [Microsoft.SqlServer.Replication.scriptoptions]::IncludeCreateSnapshotAgent `
               -bor  [Microsoft.SqlServer.Replication.scriptoptions]::IncludePublicationAccesses `
               -bor  [Microsoft.SqlServer.Replication.scriptoptions]::IncludeArticles `
               -bor  [Microsoft.SqlServer.Replication.scriptoptions]::IncludeSubscriberSideSubscriptions `
               -bor  [Microsoft.SqlServer.Replication.scriptoptions]::IncludeGo `


    foreach($Database in $ReplSvr.ReplicationDatabases)
    {
        if ($Database.TransPublications.Count -gt 0)
        {
            foreach($TranPub in $Daatbase.TransPublications)
            {
                [string] $PubScript = $TranPub.script($ScriptOptions)

                $PubScript >> $OutputFile"" >> $OutputFile
            }
        }
    }

    foreach($Database in $ReplSvr.ReplicationDatabases)
    {
        if ($Database.MergePublications.Count -gt 0)
        {
            foreach($MergePub in $Database.MergePublications)
            {
                [string] $PubScript = $MergePub.script($ScriptOptions)

                $PubScript >> $OutputFile"" >> $OutputFile
            }
        }
    }


John M. Couch

Oracle to SQL Replication LogReader Error

$
0
0


Here are the error messages, any help will be greatly appreciated.  Would like to know if there's a way to see the records that is causing the error and if not, can we skip it?  

ORA-01455: converting column overflows integer datatype (Source: MSSQL_REPL_ORACLE, Error number: 1455)
Get help: http://help/1455

Heterogeneous Logreader encountered an error in call to LoadReplCmds when processing state 'FETCH'. (Source: MSSQL_REPL, Error number: MSSQL_REPL22037)
Get help: http://help/MSSQL_REPL22037


tae yang


Replication Error in SQL server 2008 R2

$
0
0
The job failed.  The Job was invoked by User .  The last step to run was step 3 (Detect nonlogged agent shutdown.).

Can't see the publisher in Replication Monitor

$
0
0

 Hi, I have around 10 publishers in my replication Monitor. I m able to see everything fine, But one of the publishers has the cross mark and I can't see any publications in it. If I right click on it and connect to distributor, it connects and when I go to other server it again disconnects. I have to again rt click and connect to distributor to see the publications. How can I fix this? Please advise

 

Thank you

Not able to delete distribution database in sql 2012 transactional replication

$
0
0
Not able to delete distribution database from transactional replication from publisher node although was able to successfully remove publication and subscription in sql 2012.pls if any one can tell me what has gone wrong??I tried using SP for removing distribution database but it gives error...

srm_2010

Value lost for Max Text Size

$
0
0

Hi,

We have a SQL2008R2 box, replicating via transactional replication out to a second SQL2008R2 box. This has been in place and working well for 18 months, or so. The fields replicated are regularly very large in size.

Suddenly, this week, there was an error indicating that the max text size value was not adequate for the data being replicated - i.e. the value of 65536 wasn't big enough.

The problem is that, since we set up replication, this value was set to 2147483637 to avoid this very issue.

When opening up the Server Properties window, the value is still quite clearly set to 2147483637, even though the synchronisation status shows an error of "length of LOB data (xxxxx) to be replicated exceeds configured maximum 65536".

The only thing I can think of that has changed on that box is the account under which the replication credentials were running. Another user was specified, albeit with the same permissions - could this have kyboshed things?

Before I reset the Max Text Size setting (with the same value indicated), I would like to know if anyone has any idea of what is going on. This is a system on which I can't really afford to spend time "playing".

Thanks,
PaulG


PaulG

Moving data files to new drives for Publisher/Subscriber databases

$
0
0

Greetings, we are moving our SQL Server 2012 database environment to new storage. We have a distributed environment where we have our application databases on 1 server, transactional replication of our app databases to a second server for reporting and a third server for the distribution server. I am wondering what the best practice would be for doing this. The steps below are what I am considering:

1) Backup databases
2) either a restore or ALTER DATABASE MODIFY FILE?

The problem is replication. I need to remove it and have done so on the publisher using sp_ReplicationDBOption setting the publisher to false. What needs to be done on the Distribution server (Stop SQL Agent?) and then on the subsciber database, what needs to be done there? Thank you.


Is it possible to replicate the tables on same database with different table names and compatible datatypes

$
0
0

Hi,

I am looking for, replicating  the couple of tables in a same database to other tables with different name and different datatypes?

thanks,

Merge Replication Error, looking for advice

$
0
0
Hello All, I have a weird issue that has sprung up on a not so common configuration

cliffs
started a new job recently
a lot of the stuff set up was done a fair amount of time ago
still exploring configurations / setups
come into work today to find merge replication failing and peeling back the layers of the onion have let to one road block after another.


Basics
Publisher / distributor = 2008r2 sp3
subscriber = 2012 sp2

subscriber is also part of an availability group

This past weekend there was a failover (windows patching) and now the merge replication is pointing to the new primary and failing.

After discussing with the other DBA he enlighted me to the following (which goes through the steps of fixing the broken subscription)

https://msdn.microsoft.com/en-us/library/hh882436.aspx

Going through the steps listed, I find another issue when using the GUI ("for merge publications, the subscriber must not exceed the version of the publisher).

SO...that was a little shock, since this has been apparently functioning for quite some time, and I have no idea how it was originally set up as that wasn't documented and the person doesn't work here (ever heard that one before!!!)

I can, however add the subscription via t-sql without error and it looks like it starts working again...but here is the weird part.


I add the subscription, then run the snapshot agent, then start the synchronization...replication starts the application of the snapshot, and it looks like it makes it all the way through the process...the row counts match at each end...

Then it appears at the end of the sync tasks, it has an issue and blows up with the following error


2015-09-08 15:42:26.194 The merge process was unable to deliver the snapshot to the Subscriber.
If using Web synchronization, the merge process may have been unable to create or write to the message file. When troubleshooting, restart the synchronization with verbose history logging and specify an output file to which to write.


shortly followed by:

Message: Cannot find the object 'MSmerge_ctsv_FFC1150006B248139828C108E0C87137', because it does not exist or you do not have permission.

it is a push subscription, I cannot for the life of me figure out if this is a windows permissions error or something database related...or now the fact that this current set up shouldn't have ever worked based on the GUI error I got.


Any help or comments are appreciated.

Thanks in advance,

Lee


Disable constraint creation for subscriber

$
0
0

Hello,

 

It seems we have a table that is on merge replication the table by default doesn't have a PK on it. This table only has about 50 rows of data, somewhere during the initialization process it's trying to create a PK by default on the client end. My assumption is during the creation of the snapshot a script is being generated that we do not want. How can we prevent them from happening as it's creating a PK violation.

 

The schema script 'if object_id(N'[dbo].[checklistimported]') is not null exec('ALTER TABLE [dbo].[checklistimported] ADD CONSTRAINT
 PK_listimported PRIMARY KEY CLUSTERED
 (
 projectid,
 chklstid,
 unit,
 lot
 ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]

')' could not be propagated to the subscriber due to an error in creating index. A possible cause of this error is one or more join filters has the join_unique_key property se

 

server SQL2k5 SP1

client SQL Express

merge rep identity range not adjusting in timely fashion

$
0
0

Good Day all,

Strange issue with identity ranges in merge replication,  can anyone shed any light ?

Occurred when running a couple of updates (one of 12,000 rows and the other of 50,000) on the sql2008 publisher.  Identity range is 10,000 and the treshold 80%.

We split the updates up into tranches of 1,000 with a call to sp_adjustpublisheridentityrange between each.
Expected this would mean identity ranges would be adjusted appropriately as and when.

But when running the script we did encounter error stating identity range exhausted.

Any ideas why this should be ?  Is it necessary to add a delay after running sp_adjustpublisheridentityrange
to ensure it 'propagates' ?

How to clean up system tables like sysmergepublications , sysmergesubscriptions

$
0
0

Hi ALL,

        How to clean up system tables like sysmergepublications , sysmergesubscriptions...

'NewHotel' in my subscriber database i still see the Overdue publihser details in these system tables Same thing in publisher database....

how to remove all these data .....when i reinitialize database at subscriber ..and if i see the local subscriptions in ssms there are subscriptions from publishers to which it is subscribed before..and i cant delete this.... It will be restore for a later When i delete .

I have tried : "delete FROM sysmergepublications WHERE pubid='<Overdue publihser ID>' " "delete FROM sysmergesubscriptions WHERE pubid='<Overdue publihser ID>' " sp_mergesubscription_cleanup.

 but all no used. Successful delete but restore for a later.

Merge replication metadata deletion error MSSQL_REPL-2147199402

$
0
0

I setup merge replication about 3 weeks ago between a few databases all running SQL 2008 SP1:

  • DB1 - This database is the publisher and distributor.
  • DB2 - This database is a write-only subscriber (-EXCHANGETYPE 1) to DB1.
  • DB3 - This database is a write-only subscriber (-EXCHANGETYPE 1) to DB1.
  • DB4 - This database is a write-only subscriber (-EXCHANGETYPE 1) to DB1.
  • DB5 - This database is a read-only subscriber (-EXCHANGETYPE 2) to DB1.
  • DB6 - This database is a read-only subscriber (-EXCHANGETYPE 2) to DB1.

Everything was running fine, then suddenly one at a time the replication jobs for DB2, DB3, and DB4 all started reporting the error:

The Merge Agent failed after detecting that retention-based metadata cleanup has deleted metadata at the Publisher for changes not yet sent to the Subscriber. You must reinitialize the subscription (without upload). (Source: MSSQL_REPL, Error number: MSSQL_REPL-2147199402)

I was able to manually upload data from DB2, DB3, and DB4 to DB1 then reinitialize the subscriptions.  However, I don't understand why only those three subscriptions failed.  I have other merge replication jobs between the same SQL instances that are still running fine.  The only unique thing I can determine about the failed subscriptions is that they are write-only.  I really don't want to make them read/write, as it would cause a lot of unnecessary network traffic to flow between them.

Based on what I've been able to gather, the subscriptions were marked as expired which caused this problem.  If I change subscriptions to never expire to get around this problem, is that going to cause my distribution DB to grow unchecked?  Are there other ways to solve this problem?

Thanks,

Matt

SQL2014 Transactional replication for Availability Group (Named Instance)

$
0
0

Hope someone out there can advise on this.  

Does the following URL apply to a Replication subscriber that is part of an AG but not on a default instance of SQL?

https://msdn.microsoft.com/en-us/library/hh882436(v=sql.120).aspx

The AG Listener is referenced using the AGL name of PSQL02-AGL + Port 8485  so  PSQL02-AGL,8485 of PSQL02-AGL\INST2

We are having issues setting up the subscriber and will post further detail info if required.  In the article I'm unsure of the requirement of a linked server and does the linked server need to contain the Subscriber database?

Any initial feedback would be most welcome.

Thanks


Viewing all 4054 articles
Browse latest View live


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