I need an urgent help to fix some data conversion issue in SQL server 2008. I got some requirement change on storing the data. Without much care I converted existing varbinary data to varchar in SQL server 2008 using "CONVERT(NVARCHAR(max), @bytearraydata, 1)".
The same conversion in C# is done using Encoding.Default.GetString and Encoding.Default.GetBytes api's. Encoding.Default.GetBytes(string) gets back the bytearray as it was earlier. But when I try to get back the byte array of string which I converted using "CONVERT() method" of SQL server 2008 gives me a wrong result.
My work is to fetch byte array stored as string (in db) and convert it to byte array and finally render the content as PDF. Data going through encoding mechanism (while saving and while fetching) works fine for me. But when I try to fetch the data which was converted using CONVERT of sql is failing to generate PDF. Its very urgent, as we have to push production release in a near time. Please help me. Thanks in advance.
Byte array column has been changed to string.
Existing data conversion done using below sql script
Convert(NVARCHAR(MAX), @bytearraydata, 1)
In application level byte array conversion is done using below code Encoding.Default.GetString(bytearraydata)
Is Encoding and CONVERT are not compatible?