Solved

Snapshot Replication via TSQL

Posted on 2011-02-15
1
529 Views
Last Modified: 2012-05-11
OK, done some looking around, and come to a road block.

We are trying to conduct a snapshot replication dynamically using VB.net. By dynamically I am meaning, that the replication needs to be done after we update data that may not always be getting updated at the same time, one week we might have two updates, the next week we might have one update on a Monday and the following week we might have one update on a Wednesday. Our vb.net code will, after everything has been updated, execute the sp_start_job SQL command to regenerate the snapshot for our "Snapshot" publication, and then it runs the sp_update_schedule SQL command to update the date that the task will execute. I have the Jobs in place to generate the new snapshots and the vb.net code that runs the sp to start the snapshot agent, and the vb.net code to update the schedule for the job.

What i am missing it the TSQL to "Reinitialize" the subscription to the replication does not fail when the distribution agent runs. I received the following error in my job history log for the distribution agent task: "The subscription(s) have been marked inactive and must be reinitialized. NoSync subscriptions will need to be dropped and recreated."

I have include the vb.net code, if it helps, omitting sensitive info like server names and such.  Any assistance would be appreciated.

Thanks
''vb.net code
  Dim command As New SqlClient.SqlCommand("EXEC msdb.dbo.sp_start_job N" & snapshotJob, localConnection)
        Dim snapshotResults As Integer = Nothing

        localConnection.Open()
        snapshotResults = command.ExecuteNonQuery()
        localConnection.Close()


        command = New SqlClient.SqlCommand("EXEC msdb.dbo.sp_update_schedule @name =" & replicationJobScheduler & ", @enabled = 1,@freq_interval =1, @active_start_date =" & runDate & ", @active_start_time=233000", localConnection)
        localConnection.Open()
        snapshotResults = command.ExecuteNonQuery()
        localConnection.Close()

Open in new window

0
Comment
Question by:cpence
1 Comment
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
Comment Utility
Try increasing the Retention period (default 72 hours)

http://www.sqlservercentral.com/Forums/Topic154744-7-2.aspx#bm1025763
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

In this article I will describe the Detach & Attach method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now