I have a problem when I am trying to move a varbinary(max) field from one DB to another. If I insert like this: 0xD0CF11E0A1B11AE10000000 It results the beginning with an additional '0': 0x0D0CF11E0A1B11AE10000000
And I cannot get rid of this. I've tried many tools, like SSMS export tool or BCP, but without any success. And it would be better fro me to solve it in a script anyway.
And don't have much kowledge about varbinary (a program generates it), my only goal is to copy it:)
1条答案
按热度按时间4szc88ey1#
This value contains an odd number of characters. Varbinary stores bytes. Each byte is represented by exactly two hexadecimal characters. You're either missing a character, or your not storing bytes.
Here, SQL Server is guessing that the most significant digit is a zero, which would not change the numeric value of the string. For example:
Or:
It's just a difference of SQL Server assuming that varbinary always represents bytes.