0

In SQL Server, a varbinary(max) looks like '0xFE12CE34AB27' when looking at query results in a grid result within Management Studio. How can I copy a value looking like that and convert it back into a byte array via C#?

James Alexander
  • 6,132
  • 10
  • 42
  • 56
  • 2
    So just to clarify, you're *copying the string value* (e.g. via the clipboard) - this isn't about fetching from the database in C#? – Jon Skeet Oct 10 '12 at 19:17
  • 1
    http://stackoverflow.com/questions/3916049/convert-sql-binary-to-byte-array – mgidell Oct 10 '12 at 19:17
  • If you retrieve the value from the database using C# it wont be in a string representation. Also Management Studio might not be showing the complete binary file but rather the first part of it. – Magnus Oct 10 '12 at 19:18
  • Jon, you're correct, I'm just trying to copy and paste the value into LinqPad to decode it as I'm just trying to troubleshoot something quickly. – James Alexander Oct 10 '12 at 19:23

1 Answers1

1

The '0xFE12CE34AB27' string you see is an artifact of the Mgmt Studio.

Your data already is a byte array, don't do anything.

H H
  • 263,252
  • 30
  • 330
  • 514