{"id":1395,"date":"2021-06-27T21:37:47","date_gmt":"2021-06-27T13:37:47","guid":{"rendered":"https:\/\/www.yohz.com\/blogs\/?p=1395"},"modified":"2022-07-07T10:36:52","modified_gmt":"2022-07-07T02:36:52","slug":"extracting-files-from-a-progresscrm-database","status":"publish","type":"post","link":"https:\/\/www.yohz.com\/blogs\/2021\/06\/27\/extracting-files-from-a-progresscrm-database\/","title":{"rendered":"Extracting files from a ProgressCRM database"},"content":{"rendered":"<p>We recently had a user who needed to extract files from a SQL Server database created by ProgressCRM and needed help.\u00a0 He was helpful enough to send us a couple of the sample files that were not extracted correctly.<\/p>\n<p>It turned out that each file that was being uploaded was stored in an OLE container.\u00a0 Normally, our products (<a href=\"https:\/\/www.yohz.com\/siv8_details.htm\">SQL Image Viewer<\/a>, <a href=\"https:\/\/www.yohz.com\/aole_details.htm\">Access OLE Export<\/a>, and <a href=\"https:\/\/www.yohz.com\/sbe_details.htm\">SQL Blob Export<\/a>) can extract the embedded files, but in this case, the entire OLE container itself had a 12-byte prefix, most likely added by ProgressCRM for their internal use.<\/p>\n<p>So the task was to first extract the content without the 12-byte prefix, and then let <a href=\"https:\/\/www.yohz.com\/sbe_details.htm\">SQL Blob Export<\/a> handle the extraction of the files from the OLE container.<\/p>\n<p>Luckily, this was easy enough to do in a SQLServer database.\u00a0 We could use the SUBSTRING command to retrieve only the content from the 13-th byte onwards e.g.<\/p>\n<p>SELECT <strong>SUBSTRING<\/strong>(CAST(<u>&lt;the column containing the binary data&gt;<\/u> AS VARBINARY(MAX)), <strong>13<\/strong>, DATALENGTH(content))\u00a0 FROM <u>&lt;the table name&gt;<\/u><\/p>\n<p>So if you find that your application is uploading your files with their own prefix data, you can use the SUBSTRING function (in SQL Server) to remove the prefix so that our products can recognize the actual file content and export them for you correctly.<\/p>\n<div class=\"fcbkbttn_buttons_block\" id=\"fcbkbttn_left\"><div class=\"fcbkbttn_like \"><fb:like href=\"https:\/\/www.yohz.com\/blogs\/2021\/06\/27\/extracting-files-from-a-progresscrm-database\/\" action=\"like\" colorscheme=\"light\" layout=\"button\"  size=\"small\"><\/fb:like><\/div><div class=\"fb-share-button  \" data-href=\"https:\/\/www.yohz.com\/blogs\/2021\/06\/27\/extracting-files-from-a-progresscrm-database\/\" data-type=\"button\" data-size=\"small\"><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>We recently had a user who needed to extract files from a SQL Server database created by ProgressCRM and needed help.\u00a0 He was helpful enough to send us a couple of the sample files that were not extracted correctly. It turned out that each file that was being uploaded was stored in an OLE container.\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":[17,44,5,11],"tags":[18,48,12],"_links":{"self":[{"href":"https:\/\/www.yohz.com\/blogs\/wp-json\/wp\/v2\/posts\/1395"}],"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=1395"}],"version-history":[{"count":2,"href":"https:\/\/www.yohz.com\/blogs\/wp-json\/wp\/v2\/posts\/1395\/revisions"}],"predecessor-version":[{"id":1756,"href":"https:\/\/www.yohz.com\/blogs\/wp-json\/wp\/v2\/posts\/1395\/revisions\/1756"}],"wp:attachment":[{"href":"https:\/\/www.yohz.com\/blogs\/wp-json\/wp\/v2\/media?parent=1395"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yohz.com\/blogs\/wp-json\/wp\/v2\/categories?post=1395"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yohz.com\/blogs\/wp-json\/wp\/v2\/tags?post=1395"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}