Solved

Snapshot Replication via TSQL

Posted on 2011-02-15
1
546 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

There have been several questions about Large Transaction Log Files in SQL Server 2008, and how to get rid of them when disk space has become critical. This article will explain how to disable full recovery and implement simple recovery that carries…
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…

627 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