Join to MSrepl_Commands table xact_seqno field which is varbinary to a varchar value retreived elsewhere produces 0 results.

The following code yeilds zero results.

DECLARE @SEQNO Varbinary(100)

SET @SEQNO = (select CONVERT(VARBINARY,LAST_POSITION) FROM DI_CDCTest.dbo.AL_CDC_CHECKPOINT where CDC_TABLE = 'JDEGAACCOUNTBALANCES')

SELECT com.xact_seqno, tr.entry_time, com.partial_command, com.command
FROM MSrepl_transactions tr, MSrepl_commands com
WHERE  com.publisher_database_id = 2
AND      com.article_id = 10
AND      tr.xact_seqno=com.xact_seqno
AND   com.xact_seqno = @SEQNO
ORDER BY com.xact_seqno, com.command_id

If I hard code @SEQNO with 0x0000272C0000111E0001  It works.

Why does a conversion from the varchar field of value 0000272C0000111E0001 return this 0x3030303032373243303030303131314530303031.  ????

I have a varchar field that contains 0000272C0000111E0001  I need to compare this to xact_seqno in msrepl_commands.  How can I do this?  Any help is Much appreciated.  Thanks

rryffAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

rryffAuthor Commented:
Found the solution:  The following works

DECLARE @SEQNO AS VARCHAR(100)

USE DI_CDCTest

SELECT
      @SEQNO = '0x' + MIN(CP.LAST_POSITION)
FROM AL_CDC_CHECKPOINT CP

USE distribution
declare @string varchar(2000)

set @string = 'Select * From MSRepl_Commands Where xact_seqno >= '+ @SEQNO

exec (@string)
0
EE_AutoDeleterCommented:
rryff,
Because you have presented a solution to your own problem which may be helpful to future searches, this question is now PAQed and your points have been refunded.

EE_AutoDeleter
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.