Solved

Snapshot Replication via TSQL

Posted on 2011-02-15
1
543 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

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Hi all, It is important and often overlooked to understand “Database properties”. Often we see questions about "log files" or "where is the database" and one of the easiest ways to get general information about your database is to use “Database p…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

808 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