{"id":1213,"date":"2021-02-04T21:44:09","date_gmt":"2021-02-04T13:44:09","guid":{"rendered":"https:\/\/www.yohz.com\/blogs\/?p=1213"},"modified":"2022-08-11T22:23:58","modified_gmt":"2022-08-11T14:23:58","slug":"extracting-attachments-from-an-access-table-using-access-ole-export-or-sql-blob-export","status":"publish","type":"post","link":"https:\/\/www.yohz.com\/blogs\/2021\/02\/04\/extracting-attachments-from-an-access-table-using-access-ole-export-or-sql-blob-export\/","title":{"rendered":"Extracting attachments from an Access table using Access OLE Export or SQL Blob Export"},"content":{"rendered":"<p><a href=\"https:\/\/www.yohz.com\/aole_details.htm\">Access OLE Export<\/a> 4 and <a href=\"https:\/\/www.yohz.com\/sbe_details.htm\">SQL Blob Export<\/a> 4 have added support to extract files from attachment-type columns in Microsoft Access tables.<\/p>\n<p>Say we have a table named <strong>table001<\/strong> with the following structure:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1205\" src=\"https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2021\/02\/accessattachment02.png\" alt=\"\" width=\"408\" height=\"159\" srcset=\"https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2021\/02\/accessattachment02.png 408w, https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2021\/02\/accessattachment02-300x117.png 300w\" sizes=\"(max-width: 408px) 100vw, 408px\" \/><\/p>\n<p>Attachment-type columns in Access contain sub-columns that contains details of one or more attachments stored in that row.\u00a0 If we just select the table during the export process like this:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1217\" src=\"https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2021\/02\/aoe_attachment03.png\" alt=\"\" width=\"543\" height=\"332\" srcset=\"https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2021\/02\/aoe_attachment03.png 543w, https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2021\/02\/aoe_attachment03-300x183.png 300w\" sizes=\"(max-width: 543px) 100vw, 543px\" \/><\/p>\n<p><a href=\"https:\/\/www.yohz.com\/aole_details.htm\">Access OLE Export<\/a> \/ <a href=\"https:\/\/www.yohz.com\/sbe_details.htm\">SQL Blob Export<\/a> (version 4.10 onwards) will automatically detect that the <strong>files<\/strong> column is a attachment-type column.\u00a0 It will then retrieve the <strong>FileName<\/strong>, <strong>FileData<\/strong>, and <strong>FileType<\/strong> subcolumns, and export the content from the <strong>FileData<\/strong> column using the file name value from the <strong>FileName<\/strong> column.<\/p>\n<p>However, if you want to name the exported files differently, you will need to use the <strong>Extract items using SQL query<\/strong> option.\u00a0 What we need to do is to enter a query to retrieve the sub-column (<strong>FileData<\/strong>) that contains the actual file contents.\u00a0 The other useful sub-column is <strong>FileName<\/strong>, which stores the original file name.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1218\" src=\"https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2021\/02\/aoe_attachment04.png\" alt=\"\" width=\"542\" height=\"250\" srcset=\"https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2021\/02\/aoe_attachment04.png 542w, https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2021\/02\/aoe_attachment04-300x138.png 300w\" sizes=\"(max-width: 542px) 100vw, 542px\" \/><\/p>\n<p>We select the sub-columns by entering the column name (<strong>files<\/strong>), followed by a dot (.), then the sub-column name.\u00a0 In the example above, to retrieve the contents of the attachment column, we enter<\/p>\n<p><strong>files.FileData<\/strong><\/p>\n<p>and to retrieve the original file name, we enter<\/p>\n<p><strong>files.FileName<\/strong><\/p>\n<p>Now if we want to, we can name the exported files using the original file name.\u00a0 Enter<\/p>\n<p><strong>&lt;filename&gt;<\/strong><\/p>\n<p>as the column to use to name all the files that are exported, in the <strong>Other types<\/strong> section.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1219\" src=\"https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2021\/02\/aoe_attachment05.png\" alt=\"\" width=\"553\" height=\"514\" srcset=\"https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2021\/02\/aoe_attachment05.png 553w, https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2021\/02\/aoe_attachment05-300x279.png 300w\" sizes=\"(max-width: 553px) 100vw, 553px\" \/><\/p>\n<p><a href=\"https:\/\/www.yohz.com\/aole_details.htm\">Access OLE Export<\/a> or <a href=\"https:\/\/www.yohz.com\/sbe_details.htm\">SQL Blob Export<\/a> will then export each attachment returned by your query, and name the files using the original file names.\u00a0 Of course, you can still use a <a href=\"https:\/\/www.yohz.com\/blogs\/2020\/05\/08\/naming-the-exported-files-in-access-ole-export-and-sql-blob-export\/\">different naming convention<\/a> if you need to do so.<\/p>\n<p>But say we want to add the <strong>ID<\/strong> value to the file name, as there may be duplicate file names.\u00a0 We could then enter <strong>&lt;ID&gt;_&lt;filename&gt;<\/strong> for the file naming convention, and our exported files will contain the <strong>ID<\/strong> value.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1806\" src=\"https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2021\/02\/attachment02.png\" alt=\"\" width=\"584\" height=\"106\" srcset=\"https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2021\/02\/attachment02.png 584w, https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2021\/02\/attachment02-300x54.png 300w\" sizes=\"(max-width: 584px) 100vw, 584px\" \/><\/p>\n<p>We could further format the ID value to 4 digits, if we want it sorted neatly in Windows Explorer.\u00a0 For e.g. instead of exported files named <strong>1_contract.pdf<\/strong>, <strong>2_invoice.pdf<\/strong>, <strong>3_quotation.pdf<\/strong>, we could enter the naming convention value:<\/p>\n<p><strong>&lt;ID:0000&gt;_&lt;filename&gt;<\/strong><\/p>\n<p>and our exported files would be named <strong>0001_contract.pdf<\/strong>, <strong>0002_invoice.pdf<\/strong>, <strong>0003_quotation.pdf<\/strong><\/p>\n<p>So if you have a ton of images that you need to export, give <a href=\"http:\/\/www.yohz.com\/aole_details.htm\">Access OLE Export<\/a> or <a href=\"https:\/\/www.yohz.com\/sbe_details.htm\">SQL Blob Export<\/a>\u00a0a try.<\/p>\n<div class=\"fcbkbttn_buttons_block\" id=\"fcbkbttn_left\"><div class=\"fcbkbttn_like \"><fb:like href=\"https:\/\/www.yohz.com\/blogs\/2021\/02\/04\/extracting-attachments-from-an-access-table-using-access-ole-export-or-sql-blob-export\/\" action=\"like\" colorscheme=\"light\" layout=\"button\"  size=\"small\"><\/fb:like><\/div><div class=\"fb-share-button  \" data-href=\"https:\/\/www.yohz.com\/blogs\/2021\/02\/04\/extracting-attachments-from-an-access-table-using-access-ole-export-or-sql-blob-export\/\" data-type=\"button\" data-size=\"small\"><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>Access OLE Export 4 and SQL Blob Export 4 have added support to extract files from attachment-type columns in Microsoft Access tables. Say we have a table named table001 with the following structure: Attachment-type columns in Access contain sub-columns that contains details of one or more attachments stored in that row.\u00a0 If we just select [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[17,44],"tags":[133,18,48],"_links":{"self":[{"href":"https:\/\/www.yohz.com\/blogs\/wp-json\/wp\/v2\/posts\/1213"}],"collection":[{"href":"https:\/\/www.yohz.com\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yohz.com\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yohz.com\/blogs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yohz.com\/blogs\/wp-json\/wp\/v2\/comments?post=1213"}],"version-history":[{"count":4,"href":"https:\/\/www.yohz.com\/blogs\/wp-json\/wp\/v2\/posts\/1213\/revisions"}],"predecessor-version":[{"id":1807,"href":"https:\/\/www.yohz.com\/blogs\/wp-json\/wp\/v2\/posts\/1213\/revisions\/1807"}],"wp:attachment":[{"href":"https:\/\/www.yohz.com\/blogs\/wp-json\/wp\/v2\/media?parent=1213"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yohz.com\/blogs\/wp-json\/wp\/v2\/categories?post=1213"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yohz.com\/blogs\/wp-json\/wp\/v2\/tags?post=1213"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}