M
Mark Olbert
I've been wrestling with slow performance of a SqlServer 2008 database that stores PDFs in image fields.
The table is very simple, with an int primary index column and an image field, called 'data', to hold the binary data. When you
bring the table up in Access you're able to right-click on the data field and select "Insert Object". From there you can browse to a
PDF and insert it. Once you've inserted the file you can double-click the field and Acrobat will launch and display the field
contents.
However, what actually gets inserted in the data field is much, much larger than the actual file you select. For example, a 40K PDF
gets stored as a 7.5MB field. I verified this by calling DATALENGTH() on the data field. So a great deal of data above and beyond
the actual file content is being stored.
You >>can<< store just the file content by doing something like this:
INSERT INTO test(idnum, data) VALUES(1, 0x0)
UPDATE test set data = (SELECT * FROM OPENROWSET(BULK 'path to PDF', SINGLE_BLOB) AS x )
WHERE idnum=1
That set of operations stores just the file data in the field (again, I verified this via DATALENGTH()). But there's a catch: Access
no longer "knows" what's in the field, so you can't double-click it to display it.
So apparently the "extra" data that gets stored has something to do with storing the "context" or "management application" for the
field contents.
But what is the extra information? And can I configure Access to store just the file contents, and not the context?
- Mark
The table is very simple, with an int primary index column and an image field, called 'data', to hold the binary data. When you
bring the table up in Access you're able to right-click on the data field and select "Insert Object". From there you can browse to a
PDF and insert it. Once you've inserted the file you can double-click the field and Acrobat will launch and display the field
contents.
However, what actually gets inserted in the data field is much, much larger than the actual file you select. For example, a 40K PDF
gets stored as a 7.5MB field. I verified this by calling DATALENGTH() on the data field. So a great deal of data above and beyond
the actual file content is being stored.
You >>can<< store just the file content by doing something like this:
INSERT INTO test(idnum, data) VALUES(1, 0x0)
UPDATE test set data = (SELECT * FROM OPENROWSET(BULK 'path to PDF', SINGLE_BLOB) AS x )
WHERE idnum=1
That set of operations stores just the file data in the field (again, I verified this via DATALENGTH()). But there's a catch: Access
no longer "knows" what's in the field, so you can't double-click it to display it.
So apparently the "extra" data that gets stored has something to do with storing the "context" or "management application" for the
field contents.
But what is the extra information? And can I configure Access to store just the file contents, and not the context?
- Mark