September 20, 2002 at 12:48 am
Is there any way to load the contents of a binary file (located on a local file system) into a variable? I have found undocumented xp_* procedures that list and walk directory structures, tell you stats about a file, etc., but none that actually read files!!!
I have found a ridiculous way to do it (I believe)--email the file as an attachment to the SQL server and then use xp_readmail to get the attachments. I need a more straightforward way!!!
September 20, 2002 at 1:54 am
Depends on how you are trying to do this. If you're using ADO to insert it into a table or something, check this KB out:
http://support.microsoft.com/support/kb/articles/Q258/0/38.asp
Also, if you're just doing it manually, in SQL Server Resource Kit there is a nifty tool BII (Bulk Image Insert) that works like bcp, only it lets you specify a binary file on your filesystem and insert it into an image column in SQL Server. The resource kit also includes some examples on how to use ADO, OLE DB or ODBC to work with BLOB data.
Chris Hedgate @ Apptus Technologies (http://www.apptus.se)
September 20, 2002 at 12:01 pm
We are not using and are not going to use ADO, and would rather not have to use anything more than Query Analyzer. We maintain our production database server by applying patches that contain only SQL scripts executed using Query Analyzer. This allows us to maintain the database in the same manner we maintain the rest of our source code. Recently we added a content management piece to the application that involves images and such, and we would like to batch load a bunch of them when we launch the new module. bii sounds like a possible solution.
However, I cannot believe that Microsoft has gone to the trouble to write procedures that walk file directories but don't actually read files. Except for something bordering on the freakish, why would you allow someone to see the contents of a directory and not get at the contents?
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply