<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: how to insert a binary pdf into a sql database? in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/how-to-insert-a-binary-pdf-into-a-sql-database/m-p/355440#M10658</link>
    <description>&lt;P&gt;This is really an SQL Server issue not a SAS problem. Where does SQL Server expect the PDF to be so it can be loaded? A quick Google search suggests a directory location can be included but it would need to be one accessible by SQL Server. Maybe you can FTP the PDF to the SQL Server load folder using SAS, then run your load step referencing the folder.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 02 May 2017 23:42:37 GMT</pubDate>
    <dc:creator>SASKiwi</dc:creator>
    <dc:date>2017-05-02T23:42:37Z</dc:date>
    <item>
      <title>how to insert a binary pdf into a sql database?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/how-to-insert-a-binary-pdf-into-a-sql-database/m-p/355300#M10654</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I am trying to insert a pdf into a sql&amp;nbsp;database but having some trouble.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The pdf is a report created in SAS 9.4 using ods.&lt;/P&gt;
&lt;P&gt;I am connecting to the sql database using odbc connection. On the sql&amp;nbsp;server there is a sql stored procedure that is expecting the pdf as a binary object. However, I don't know how to deliver&amp;nbsp;a binary pdf in SAS.&lt;/P&gt;
&lt;P&gt;Any suggestions? Or information I need to add to make my question more clear?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is the sas&amp;nbsp;code I am using.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc sql;
&amp;nbsp; &amp;nbsp; connect to odbc ("driver={&amp;amp;driver};server=tcp:&amp;amp;server,1433;database=&amp;amp;database;uid=&amp;amp;userid@&amp;amp;server_name;pwd={&amp;amp;pwd};encrypt=yes;trustservercertificate=no;connection timeout=30;");
&amp;nbsp; &amp;nbsp; execute (
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; declare @result bit
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; declare @statusmessage varchar(100)
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; exec [dbo].[report_transfer_deliverfile]
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1,
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; "&amp;amp;filepathf\test.pdf", --how do we pass binary input here?
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 'test.pdf',
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; @result output,
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; @statusmessage output
&amp;nbsp; &amp;nbsp; ) by odbc ;
&amp;nbsp; &amp;nbsp; %put &amp;amp;sqlxrc. &amp;amp;sqlxmsg.;
&amp;nbsp; &amp;nbsp; disconnect from odbc;
quit;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I get the following error:&lt;/P&gt;
&lt;P&gt;ERROR: CLI execute error: [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Incorrect syntax near 'C:'.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am connecting to database fine. And the sql stored process is running. But it needs the binary file of the pdf, not the file path I included.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for your help.&lt;/P&gt;</description>
      <pubDate>Tue, 02 May 2017 16:16:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/how-to-insert-a-binary-pdf-into-a-sql-database/m-p/355300#M10654</guid>
      <dc:creator>RC_BLAZER</dc:creator>
      <dc:date>2017-05-02T16:16:28Z</dc:date>
    </item>
    <item>
      <title>Re: how to insert a binary pdf into a sql database?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/how-to-insert-a-binary-pdf-into-a-sql-database/m-p/355440#M10658</link>
      <description>&lt;P&gt;This is really an SQL Server issue not a SAS problem. Where does SQL Server expect the PDF to be so it can be loaded? A quick Google search suggests a directory location can be included but it would need to be one accessible by SQL Server. Maybe you can FTP the PDF to the SQL Server load folder using SAS, then run your load step referencing the folder.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 May 2017 23:42:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/how-to-insert-a-binary-pdf-into-a-sql-database/m-p/355440#M10658</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2017-05-02T23:42:37Z</dc:date>
    </item>
    <item>
      <title>Re: how to insert a binary pdf into a sql database?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/how-to-insert-a-binary-pdf-into-a-sql-database/m-p/355444#M10659</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/6304"&gt;@RC_BLAZER&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;For debugging pass-through SQL I always try and make things work running code without any SAS involvement (=using some database client like SQL Server Management Studio to connect and run code directly on the DB). Only once that works I paste the code back into a SAS SQL pass-through block.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As your SQL executes&amp;nbsp;in-database I believe your PDF must reside in a location accessible to the DB and the path must be "as seen" by the database. You probably need to talk to your DBA or the person who implemented the stored procedure in order to make this work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 May 2017 00:00:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/how-to-insert-a-binary-pdf-into-a-sql-database/m-p/355444#M10659</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2017-05-03T00:00:27Z</dc:date>
    </item>
  </channel>
</rss>

