Tuesday, March 20, 2012

Can't drop SQL Mobile subscription at Publisher

I have a program running on Pocket PCs that synchronizes with a desktop SQL database using SQL Mobile. My problem is that I can't delete old subscriptions from the publication; now the publication has 25 subscriptions and won't accept any more (limit of SQL Workgroup edition). I can delete non-SQL Mobile subcriptions just fine.

Running sp_replmonitorhelpsubscription provides this information:

subscriber: LVCONTACTSMERGE - 5FA305234F0C
subscriber_db: Program Files\PocketLVContacts\LVContacts.sdf
publisher_db: LVContacts
publication: LVContactsMerge

So I set up this bit of code:

USE LVContacts
EXEC sp_dropmergesubscription
@.publication = 'LVContactsMerge',
@.subscriber = 'LVCONTACTSMERGE - 5FA305234F0C',
@.subscriber_db = 'Program Files\PocketLVContacts\LVContacts.sdf',
@.subscription_type='all';
GO

No errors are reported, but the subscription doesn't get deleted.

I've tried shutting down SQL Server Agent (mentioned in another thread); makes no difference.

Any ideas?

--Evan

If you query sysmergesubscriptions, do you get the same values returned as|||

If you query sysmergesubscriptions, do you get the same values returned as sp_replmonitorhelpsubscription? I'm just wondering if the subscriber_db name returned is correct or not.

|||

Yes, both sysmergesubscriptions and sp_replmonitorhelpsubscription give the same subscriber_db name. Note that the name returned, i.e. 'Program Files\PocketLVContacts\LVContactsData.sdf', is the path on the mobile device.

I wonder if it is safe to manually delete a row from sysmergesubscriptions. It seems to work, but no Distributor clean-up is done.

|||

I've found where I was going wrong. The code I cited in my original post DOES work, but to see the changes you must use sysmergesubscriptions, NOT sp_replmonitorhelpsubscription. The latter apparently reflects the distribution database, which is not cleaned up when you use sp_dropmergesubscription.

When you use SQL Server Management Studio to delete a subscription on a mobile device running SQL Mobile, the subscription on the Publisher is NOT also deleted; you must do it manually (or wait until the subscription expires). But it is difficult to determine which subscription on the Publisher corresponds to the one you want to delete on the mobile Subscriber. What I did was first query the mobile Subscriber system table __sysMergeSubscriptions, note the SubscriptionID field, then query the sysmergesubscriptions on the Publisher database, and find the row with a SubID that matches. Then you can run sp_dropmergesubscription using the subscriber_server field as @.subscriber and the db_name field as @.subscriber_db.

No comments:

Post a Comment