Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Starting Snapshot Agent from a Script

Posted on 2003-10-24
5
Medium Priority
?
947 Views
Last Modified: 2009-07-29
I am modifying the schema of my db by adding a column to a table.  Then I add the column to my transactional replication publication by using sp_articlecolumn.  As a last step I want to run the snapshot agent immediately as my snapshot is now no longer valid.  What system stored procedure do I use to run an existing snapshot agent?
0
Comment
Question by:LStampfli
3 Comments
 
LVL 50

Expert Comment

by:Lowfatspread
ID: 9616117
sorry don't the 2 parameters on articlecolumn do this for You?
won't the snapshot agent job get scheduled ...?

if it doesn't then use the sp_start_job procedure...
 

[@force_invalidate_snapshot = ] force_invalidate_snapshot

Acknowledges that the action taken by this stored procedure may invalidate an existing snapshot. force_invalidate_snapshot is a bit, with a default of 0. 0 specifies that changes to the article will not cause the snapshot to be invalid. If the stored procedure detects that the change does require a new snapshot, an error will occur and no changes will be made. 1 specifies that changes to the article may cause the snapshot to be invalid, and if there are existing subscriptions that would require a new snapshot, gives permission for the existing snapshot to be marked as obsolete and a new snapshot generated.

[@force_reinit_subscription = ] force_reinit_subscription

Acknowledges that the action taken by this stored procedure may require existing subscriptions to be reinitialized. force_reinit_subscription is a bit, with a default of 0. 0 specifies that changes to the article will not cause the subscription to be reinitialized. If the stored procedure detects that the change would require subscriptions to be reinitialized, an error will occur and no changes will be made. 1 specifies that changes to the article will cause existing subscriptions to be reinitialized, and gives permission for the subscription reinitialization to occur.

0
 

Author Comment

by:LStampfli
ID: 9617102
I believe that this will cause a new snapshot to be generated on schedule, but not to cause the job to run immediately.  The wording:

"gives permission for the existing snapshot to be marked as obsolete and a new snapshot generated"

implies that a new snapshot can be generated, but not when.

I will double-check that though.  I want to force the snapshot to be created right away.

I tried sp_start_job and that definately does the trick.  I figured there was a replication stored procedure to do this because there are so many of them, but apparently not.

Thanks for the help.
0
 
LVL 8

Accepted Solution

by:
Dishan Fernando earned 1000 total points
ID: 9649176
~ Create a Job
~ Steps Tab
           -Publisher [Servername] -PublisherDB [db] -Publication [pub- name] -Subscriber [servername] -SubscriberDB [db] -Distributor [servername] -DistributorSecurityMode 1

and set type to "Replication Merge"

and run Job
0

Featured Post

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

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

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example, show how to shrink a transaction log file down to a reasonable size.

824 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