Home Forums SQL Server 2016 SQL Server 2016 - Development and T-SQL Updating a varbinary field - extra leading zero added RE: Updating a varbinary field - extra leading zero added
February 7, 2018 at 4:02 pm
pavel_hant - Wednesday, February 7, 2018 3:39 PMHello,I would like to be able to update a varbinary field (named Varbinary_Data of varbinary(max) type) with a value copied from another varbinary field. I have to do it with a script, and I cannot use a subquery to get the new data in the update statement.
The data I want to insert in the field looks like 0x504B030400...D04 and it has 43,679 digits (an odd number).
I am using this update statement:
update ImageStore
set Varbinary_Data = CONVERT(varbinary(max), 0x504B030400...D04, 1)
where Id = 1001The result is that in the updated field the data has an extra leading zero after the leading 0x, like: 0x0504B030400...D04, which makes the image unusable.
Is there a way to do the update avoiding that extra zero to be added? Thanks, Paul
Why can't you use a subquery?