Share via

initialize from lsn + @subscriptionlsn

Zuluman Ross 61 Reputation points
2020-10-12T10:22:31.207+00:00

Hello Experts,

I am setting up transactional replication for the first time on below environment.

Host1\Instance1 - Distributor + Publisher
Host2\Instance2 - Subscriber

I wanted to use "initialize from LSN" and have created below script for adding the subscription.

use [DB]
GO
exec sp_addsubscription
@publication = N'CashInvenory',
@subscriber = N'Host2\Instance2',
@destination_db = N'Cash',
@subscription_type = N'Push',
@Sync brasil _type = N'initialize from LSN',
@article = N'all',
@update_zhang _mode = N'read only',
@subscriber_type = 0,
@subscriptionlsn = ????

Publisher database backed up and restored on subscriber. LastLSN in "restore with header only" for the backup file is 37000000352000001. I need to understand how do I change this value to a hex and use it in @subscriptionlsn?

When I try below for @subscriptionlsn. Subscription gets created, but distribution agent always shows message "No replicated transactions".

37000000352000001 -> 37000:00035200:0001 -> 00009088:00008980:0001 -> 0x00009088000089800001

Initialize with backup and Snapshot works all good. My requiremnet is just to learn "Initialize from LSN".

Any help would be much appreciated.

Thanks;
Zulu

SQL Server | Other
SQL Server | Other

Additional SQL Server features and topics not covered by specific categories

0 comments No comments

Answer accepted by question author

Erland Sommarskog 134.7K Reputation points MVP Volunteer Moderator
2020-10-12T21:29:18.623+00:00

Since I does not the answer on the top of my head, I did some googling. The thread https://stackoverflow.com/questions/59482450/mssql-conversion-of-decimal-based-string-into-varbinary10-where-8-byte-part-ex looks promising. There is a link to a blog post by the late Robert L Davis in that post that also can be helpful.

Was this answer helpful?

0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.