Groups | Blog | Home
all groups > sql server replication > january 2004 >

sql server replication : Replication stored procedure to start snapshot agent



sqlserverreplication2000 NO[at]SPAM yahoo.com
1/14/2004 11:03:19 AM
I am using SQL Server 2000 to replicate data to a remote MSDE. I am
using a pull subscription on my MSDE. I need to be able to
programmatically stop the pull subscription and then programmatically
restart it.

I am currently trying to use stored procedures. I do not know how to
stop the pull subscription using a stored procedure. I think I should
be able to restart it using sp_reinitpullsubscription. However even
after reinitializing the subscription, I must somehow get the snapshot
agent on the server to run.
What is the stored procedure to stop a pull subscription?
Kestas
1/15/2004 10:22:12 AM
Most probably you only need to stop and start merge agent (if you are using
merge replication).
You can get Id of merge agent job by executing following statement:

DECLARE @merge_agent_jobid binary(16)

-- Get Merge replication agent job ID

SELECT @merge_agent_jobid = MERGE_JOBID
FROM SYSMERGESUBSCRIPTIONS
JOIN MSMERGE_REPLINFO
ON SUBID = REPID
WHERE PUBLICATION = @PUBLICATION_NAME
AND SUBSCRIBER_SERVER = @SUBSCRIBER_SERVER
AND DB_NAME = @SUBSCRIBER_DATABASE

If you are using transactional replication you will need to select data from
different tables..

--
_______________________
Kestutis Adomavicius
Consultant
UAB "Baltic Software Solutions"

[quoted text, click to view]

AddThis Social Bookmark Button