I'm trying to INSERT a zip file into an MSSQL table. The table structure is such:
CREATE TABLE [dbo].[zips](
[id] [int] IDENTITY(1,1) NOT NULL,
[timestamp] [varchar](50) NULL,
[inserted] [varchar](50) NULL,
[filename] [varchar](50) NULL,
[raw_file] [varbinary](max) NULL
) ON [PRIMARY]
...nothing too fancy.
When I insert a text file, everything is well and I'm able to retrieve the text content successfully without any problems, but when I insert a binary file such as zip, the binary data gets modified.
My guess is that MSSQL somehow replaces the NON-PRINTABLE characters it gets to something default.
The zip data I'm trying to insert is:
0x504b0304140000080800715f303b607f...
but what ends up in the MSSQL table is (which is wrong):
0x504B030414C080C0800808C080715F303B607F...
notice how the 00's get replaced with C0 80
text data in:
0x
2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a
2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a
2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a
2a2a0d0a202050726f63657373696e672
0536c6f74203d2031200d0a2a2a2a2a2a
2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a
2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a
2a2a2a2a2a2a2a2a2a2a2a2a2a0d0a0d
0a70617373776f726420414454524f
text data out (which is correct):
0x
2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A
2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A
2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A
2A2A0D0A202050726F63657373696E672
0536C6F74203D2031200D0A2A2A2A2A2A
2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A
2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A
2A2A2A2A2A2A2A2A2A2A2A0D0A0D
0A70617373776F726420414454524F
Any help will be greatly appreciated. I have zero experience with SQL, and I'm really struggling with this. Thank you!