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#?
-
2So 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– Jon Skeet2012-10-10 19:17:16 +00:00Commented Oct 10, 2012 at 19:17
-
1stackoverflow.com/questions/3916049/…mgidell– mgidell2012-10-10 19:17:43 +00:00Commented 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.Magnus– Magnus2012-10-10 19:18:13 +00:00Commented 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.James Alexander– James Alexander2012-10-10 19:23:47 +00:00Commented Oct 10, 2012 at 19:23
Add a comment
|
1 Answer
The '0xFE12CE34AB27' string you see is an artifact of the Mgmt Studio.
Your data already is a byte array, don't do anything.
3 Comments
James Alexander
I'm trying to copy the artifact into linqpad as a string.
Henk Holterman
Then say 'via Clipboard', not 'via C#'. Seems like you're using the wrong tool(s) here.
Magnus
@JamesAlexander You are not guaranteed to get the complete binary file if you do it like that. Mgmt Studio cuts the data.