Solved

Snapshot Replication via TSQL

Posted on 2011-02-15
1
531 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
ID: 34905645
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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article I will describe the Copy Database Wizard 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.
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

895 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

17 Experts available now in Live!

Get 1:1 Help Now