Does anyone know how to dynamically set the -SubscriberDB name for the distributor agent job in snapshot replication?

I have a scenario where I want to switch this between two databases, depending on which one the customer is using. Essentially the unused one is inactive, and the one I want the snapshot to be applied to.

This is the command in the Replication Distributor job, I am trying to dynamically set the -SubscriberDB name.

-Publisher [server_name] -PublisherDB [publisher_database_name] -Publication [publication_name] -Distributor [distributor_name] -SubscriptionType 1 -Subscriber [subscriber_server] -SubscriberSecurityMode 1 -SubscriberDB [subscriber_database_name]


  • Have you tried to declare a variable, assign the value based on your condition (may be if-else condition)? Pass the variable as the -SubscriberDB parameter value. – SqlWorldWide Oct 18 '18 at 1:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.