{"id":1203,"date":"2021-02-11T23:53:34","date_gmt":"2021-02-11T15:53:34","guid":{"rendered":"https:\/\/www.yohz.com\/blogs\/?p=1203"},"modified":"2022-01-04T13:10:40","modified_gmt":"2022-01-04T05:10:40","slug":"extracting-attachments-from-an-access-database-using-sql-image-viewer","status":"publish","type":"post","link":"https:\/\/www.yohz.com\/blogs\/2021\/02\/11\/extracting-attachments-from-an-access-database-using-sql-image-viewer\/","title":{"rendered":"Extracting attachments from an Access database using SQL Image Viewer"},"content":{"rendered":"<p>Access has a curiously interesting data type &#8211; attachment.<\/p>\n<p>I say interesting because it does so much, but much of it is done behind the scenes.\u00a0 To the user, it&#8217;s just so easy to attach one or or more files to that column.<\/p>\n<p>For starters, some file types seem to be compressed automatically by Access.\u00a0 I attached a 23 MB text file, and the database size only increased by 3 MB, which is about the size of what my text file would have compressed to.<\/p>\n<p>Also, a single attachment-type column contains 4 sub-columns in them &#8211; FileName, FileType, FileData and FileURL (for Sharepoint databases).\u00a0 These are the sub-columns we need to include in our query in SQL Image Viewer when we want to extract the files from the attachment-type columns.<\/p>\n<p>Say we have a table defined as such:<\/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>with the following data:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1204\" src=\"https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2021\/02\/accessattachment01.png\" alt=\"\" width=\"513\" height=\"130\" srcset=\"https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2021\/02\/accessattachment01.png 513w, https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2021\/02\/accessattachment01-300x76.png 300w\" sizes=\"(max-width: 513px) 100vw, 513px\" \/><\/p>\n<p>Row 1 has 1 attachment, and row 2 has 2 attachments.\u00a0 If we run a query that selects just the 3 columns from the table in SQL Image Viewer, we get this:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1207\" src=\"https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2021\/02\/accessattachment04.png\" alt=\"\" width=\"489\" height=\"349\" srcset=\"https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2021\/02\/accessattachment04.png 489w, https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2021\/02\/accessattachment04-300x214.png 300w\" sizes=\"(max-width: 489px) 100vw, 489px\" \/><\/p>\n<p>The <strong>files<\/strong> column, which is the attachment-type column, displays only the names of the attached files, and is returned as a text column.\u00a0 If however we selected the sub-columns:<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1208\" src=\"https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2021\/02\/accessattachment05.png\" alt=\"\" width=\"716\" height=\"550\" srcset=\"https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2021\/02\/accessattachment05.png 716w, https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2021\/02\/accessattachment05-300x230.png 300w, https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2021\/02\/accessattachment05-624x479.png 624w\" sizes=\"(max-width: 716px) 100vw, 716px\" \/><\/p>\n<p>Access returns 3 rows instead of 2.\u00a0 Because our 2nd row contained 2 attachments, Access returns 2 data rows, one for each attachment.<\/p>\n<p>Thus, to extract the data from the attachment-type columns in SQL Image Viewer, we need to select the <strong>filedata<\/strong> sub-column of the attachment-type column.<\/p>\n<p>Since we added support for attachment-type columns in SQL Image Viewer 11, the same query above now returns this:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1210\" src=\"https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2021\/02\/accessattachment06.png\" alt=\"\" width=\"712\" height=\"539\" srcset=\"https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2021\/02\/accessattachment06.png 712w, https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2021\/02\/accessattachment06-300x227.png 300w, https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2021\/02\/accessattachment06-624x472.png 624w\" sizes=\"(max-width: 712px) 100vw, 712px\" \/><\/p>\n<p><a href=\"https:\/\/www.yohz.com\/downloads\/sqlblobviewer\/SQLImageViewerSetup.zip\">Download<\/a> a 14-day trial of <a href=\"https:\/\/www.yohz.com\/siv8_details.htm\">SQL Image Viewer<\/a> now and experience how easy it is to extract attachments from your Access databases.<\/p>\n<div class=\"fcbkbttn_buttons_block\" id=\"fcbkbttn_left\"><div class=\"fcbkbttn_like \"><fb:like href=\"https:\/\/www.yohz.com\/blogs\/2021\/02\/11\/extracting-attachments-from-an-access-database-using-sql-image-viewer\/\" 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\/11\/extracting-attachments-from-an-access-database-using-sql-image-viewer\/\" data-type=\"button\" data-size=\"small\"><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>Access has a curiously interesting data type &#8211; attachment. I say interesting because it does so much, but much of it is done behind the scenes.\u00a0 To the user, it&#8217;s just so easy to attach one or or more files to that column. For starters, some file types seem to be compressed automatically by Access.\u00a0 [&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":[11],"tags":[12],"_links":{"self":[{"href":"https:\/\/www.yohz.com\/blogs\/wp-json\/wp\/v2\/posts\/1203"}],"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=1203"}],"version-history":[{"count":4,"href":"https:\/\/www.yohz.com\/blogs\/wp-json\/wp\/v2\/posts\/1203\/revisions"}],"predecessor-version":[{"id":1573,"href":"https:\/\/www.yohz.com\/blogs\/wp-json\/wp\/v2\/posts\/1203\/revisions\/1573"}],"wp:attachment":[{"href":"https:\/\/www.yohz.com\/blogs\/wp-json\/wp\/v2\/media?parent=1203"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yohz.com\/blogs\/wp-json\/wp\/v2\/categories?post=1203"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yohz.com\/blogs\/wp-json\/wp\/v2\/tags?post=1203"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}