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#?

4
  • 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#? Commented Oct 10, 2012 at 19:17
  • 1
    stackoverflow.com/questions/3916049/… Commented Oct 10, 2012 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. Commented Oct 10, 2012 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. Commented Oct 10, 2012 at 19:23

1 Answer 1

1

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

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

Sign up to request clarification or add additional context in comments.

3 Comments

I'm trying to copy the artifact into linqpad as a string.
Then say 'via Clipboard', not 'via C#'. Seems like you're using the wrong tool(s) here.
@JamesAlexander You are not guaranteed to get the complete binary file if you do it like that. Mgmt Studio cuts the data.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.