Save lcoal file from SQL

I’m trying to save a local document stored in SQL db.
From execute query activity i get dt with one column(“Data”) - varbinary type…
If i’m not wrong somehow i need to transform the dt.rows(0)(“Data”) (studio is interpreting as object) to an array of bytes.

I used invoke code but the file is broken :frowning:

Dim _MemoryStream As New System.IO.MemoryStream()
Dim _BinaryFormatter As New System.Runtime.Serialization.Formatters.Binary.BinaryFormatter()
_BinaryFormatter.Serialize(_MemoryStream, inputObj)
File.WriteAllBytes(“C:\Users\Desktop\test.tiff”, _MemoryStream.ToArray())

Please help!

Hi drago47,

Did you find the solution for this? How did you fix it?

The issue was false because the binary array represented a archived pdf file - so that’s why i thought it was broken.
I had to unzip the file and then read it.
I hope this advice is useful!