Search code examples
sqlvarbinary

How to append 0s at the end of varbinary value in SQL


I have a column named abc which is Varbinary. I want to insert 0s at the end of varbinary value of fixed length.

For example

This is original value : 0x0A5445535420

And I want something like this: 0x0A5445535420200000000000000000000000000000000000000000

I tried

CONVERT(VARBINARY(64), 'abc')  

but it is not appending 0s at the end.


Solution

  • How about:

    SELECT CONVERT(VARBINARY(64), (CONVERT(BINARY(64), 'abc')))