Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It only takes a minute to sign up.
When you see -1 as the value for a VARCHAR or NVARCHAR data type, that is just a numeric representation for MAX for the .NET SQLDBTYPE as stated here.
So it looks like the application probably just stores the serialized encoded string representation of the PDF in the database in a VARCHAR(MAX) column then.
I assume the developer who designed this thought it was the easiest way to store the PDF, as opposed to VARBINARY(MAX), which would save you space (as Dan Guzman notes in the comments). Additionally it's actually best practice to not store files themselves in the database, but rather on a file system somewhere, and store the location reference to that file in the database instead.
Specifically, the value looks to be base64 encoded string of the original binary value. IMHO, it would be better to store the raw value as varbinary(MAX) to save space.
@DanGuzman Yes probably so. Likely the developer behind the app wasn't aware of this and choosing VARCHAR was the easiest solution they knew of, so they went with it, I'm guessing.
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.