The subscription does not exist

-> I was trying to create a subscription using below query on an existing transactional replication publication,

Use [JBDB]
GO
EXEC sp_addsubscription
@publication = N'JBDBREPL',
@subscriber = N'JBResearch\IN2019_1',
@destination_db = N'JBDBSub',
@sync_type= N'initialize from lsn',
@backupdevicetype='DISK',
@backupdevicename=N'c:\temp\jbdb.bak',
@subscription_type = N'push',
@subscriptionlsn =0x00000027000002500001,
@update_mode = N'read only';

-> We received below error when above query was executed,

Msg 14055, Level 11, State 1, Procedure sys.sp_MSrepl_dropsubscription, Line 178 [Batch Start Line 130]
The subscription does not exist.

-> I tried creating subscription from GUI and got below message,

You must select a Publisher and publication to continue the wizard.

-> Then I realized that the publication was created using TSQL and had no articles added,

-> I then selected required articles on the Publication and tried creating the subscription using below query,

Use [JBDB]
GO
EXEC sp_addsubscription
@publication = N'JBDBREPL',
@subscriber = N'JBResearch\IN2019_1',
@destination_db = N'JBDBSub',
@sync_type= N'initialize from lsn',
@backupdevicetype='DISK',
@backupdevicename=N'c:\temp\jbdb.bak',
@subscription_type = N'push',
@subscriptionlsn =0x00000027000002500001,
@update_mode = N'read only';

-> I got below message this time,

Msg 21399, Level 16, State 1, Procedure sys.sp_MSaddautonosyncsubscription, Line 274 [Batch Start Line 130]
The transactions required for synchronizing the subscription with the specified log sequence number (LSN) are unavailable at the Distributor. Specify a higher LSN.

-> I had to take a fresh publisher database backup and then restore it on the subscriber and had to use proper LSN to correct this. Please use this article to get more details on configuring transactional replication using Initialize from LSN.

-> Above steps will not be required if snapshot is used. As soon as article are added to the publication, you will be able to create a subscription that uses snapshot agent without any issues.

Thank You,
Vivek Janakiraman

Disclaimer:
The views expressed on this blog are mine alone and do not reflect the views of my company or anyone else. All postings on this blog are provided “AS IS” with no warranties, and confers no rights.