<?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: SQL PassThru - Multiple Database Connections in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SQL-PassThru-Multiple-Database-Connections/m-p/292088#M60568</link>
    <description>&lt;P&gt;I think your code should look something like this example. Suggest you run it past your Oracle DBA though - he should know the right syntax&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
connect to oracle as db (user="me" password="mypw" path="ibscrprd");
create table myTable as 
select * from connection to db
(select * from table_a x,table_b@OtherDatabase y where X.row_id = Y.row_id
); 
disconnect from db;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 17 Aug 2016 08:12:28 GMT</pubDate>
    <dc:creator>SASKiwi</dc:creator>
    <dc:date>2016-08-17T08:12:28Z</dc:date>
    <item>
      <title>SQL PassThru - Multiple Database Connections</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SQL-PassThru-Multiple-Database-Connections/m-p/291985#M60519</link>
      <description>&lt;P&gt;Hi. Is it possible to merge two tables that reside on two seperate databases. &amp;nbsp;In my case table ivas.ods_iv_recon_selected_mp sits on database ibscrprd, but table imapsscr.ods_bi_recon_selected_mp resides on database ivasprd. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The query below doesn't work obviously because I have only a Connect To statement for the ibscrprd database. Do you know if it's possible to connect to two databases at once using SQL PassThru? And if so, how I might alter my coding attempt below to do so?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be greatly appreciated. Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
connect to oracle as db (user="me" password="mypw" path="ibscrprd");
create table myTable as 
select * from connection to db
(select *,&lt;BR /&gt; "A" as source, &lt;BR /&gt; "-" as RuleFlag,&lt;BR /&gt; "-" as rule_nm length = 58, &lt;BR /&gt; actual_dlvry_date as ad_dt, &lt;BR /&gt; "-" as rule_order&lt;BR /&gt; from ivas.ods_iv_recon_selected_mp&lt;BR /&gt; where imb_dlvry_zip_5=&amp;amp;ZIP5_QUOTED&lt;BR /&gt; union all corresponding&lt;BR /&gt; select *,&lt;BR /&gt; "B" as source, &lt;BR /&gt; "-" as RuleFlag,&lt;BR /&gt; "-" as rule_nm length = 58, &lt;BR /&gt; actual_dlvry_date as ad_dt, &lt;BR /&gt; "-" as rule_order&lt;BR /&gt; from imapsscr.ods_bi_recon_selected_mp&lt;BR /&gt; where imb_dlvry_zip_5=&amp;amp;ZIP5_QUOTED;&lt;BR /&gt; quit;
); 
disconnect from db;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 16 Aug 2016 19:59:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SQL-PassThru-Multiple-Database-Connections/m-p/291985#M60519</guid>
      <dc:creator>buechler66</dc:creator>
      <dc:date>2016-08-16T19:59:30Z</dc:date>
    </item>
    <item>
      <title>Re: SQL PassThru - Multiple Database Connections</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SQL-PassThru-Multiple-Database-Connections/m-p/292000#M60530</link>
      <description>&lt;P&gt;As long as the databases are on the same server it should be possible. Is this the case? I know how to do it in SQL Server by establishing a connection at the server level and then including the database name on the front of the schema and table names.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm sure something similar would work for Oracle but I can't research it right now. Maybe someone else will know.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Aug 2016 22:58:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SQL-PassThru-Multiple-Database-Connections/m-p/292000#M60530</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2016-08-16T22:58:34Z</dc:date>
    </item>
    <item>
      <title>Re: SQL PassThru - Multiple Database Connections</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SQL-PassThru-Multiple-Database-Connections/m-p/292002#M60532</link>
      <description>&lt;P&gt;Yes, they are both on the same server.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Aug 2016 21:08:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SQL-PassThru-Multiple-Database-Connections/m-p/292002#M60532</guid>
      <dc:creator>buechler66</dc:creator>
      <dc:date>2016-08-16T21:08:48Z</dc:date>
    </item>
    <item>
      <title>Re: SQL PassThru - Multiple Database Connections</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SQL-PassThru-Multiple-Database-Connections/m-p/292077#M60565</link>
      <description>&lt;P&gt;Like &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13976"&gt;@SASKiwi﻿&lt;/a&gt; says, this will be Oracle specific syntax within your pass-through block of code.&lt;/P&gt;
&lt;P&gt;So research Oracle resources, or get some help from your Oracle DBA/developers.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Aug 2016 07:28:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SQL-PassThru-Multiple-Database-Connections/m-p/292077#M60565</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2016-08-17T07:28:26Z</dc:date>
    </item>
    <item>
      <title>Re: SQL PassThru - Multiple Database Connections</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SQL-PassThru-Multiple-Database-Connections/m-p/292088#M60568</link>
      <description>&lt;P&gt;I think your code should look something like this example. Suggest you run it past your Oracle DBA though - he should know the right syntax&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
connect to oracle as db (user="me" password="mypw" path="ibscrprd");
create table myTable as 
select * from connection to db
(select * from table_a x,table_b@OtherDatabase y where X.row_id = Y.row_id
); 
disconnect from db;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 17 Aug 2016 08:12:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SQL-PassThru-Multiple-Database-Connections/m-p/292088#M60568</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2016-08-17T08:12:28Z</dc:date>
    </item>
    <item>
      <title>Re: SQL PassThru - Multiple Database Connections</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SQL-PassThru-Multiple-Database-Connections/m-p/292463#M60701</link>
      <description>oh a DB Link. Unfortunately we are not allowed to have a DB Link between these two databases. &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;</description>
      <pubDate>Thu, 18 Aug 2016 14:30:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SQL-PassThru-Multiple-Database-Connections/m-p/292463#M60701</guid>
      <dc:creator>buechler66</dc:creator>
      <dc:date>2016-08-18T14:30:03Z</dc:date>
    </item>
    <item>
      <title>Re: SQL PassThru - Multiple Database Connections</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SQL-PassThru-Multiple-Database-Connections/m-p/292469#M60705</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13976"&gt;@SASKiwi﻿&lt;/a&gt;&amp;nbsp;could you show an example of how to connect to to SQL server from SAS at the server level instead of the database name? (i.e. what would go in the odbc.ini file, and how an explicit pass-through query would look)?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just the other day I was wondering if this is possible.&amp;nbsp;&amp;nbsp;&amp;nbsp;I work on one server where we have multiple databases, and it would be convenient to thave a server-level connection rather than update the OBDC.ini every time someone creates a new database.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Aug 2016 14:44:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SQL-PassThru-Multiple-Database-Connections/m-p/292469#M60705</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2016-08-18T14:44:54Z</dc:date>
    </item>
    <item>
      <title>Re: SQL PassThru - Multiple Database Connections</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SQL-PassThru-Multiple-Database-Connections/m-p/292549#M60743</link>
      <description>&lt;P&gt;Sure &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/19879"&gt;@Quentin﻿&lt;/a&gt;- this example assumes running on Windows but doing the same thing on Unix should be similar:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
 connect to odbc (noprompt = "server=MyServerName;DRIVER=SQL Server;Trusted Connection=yes;");
  create table Want  as 
  select * from connection to odbc
  (SELECT *
   FROM [MyDatabase1].[MySchema1].[Table1] as A
   INNER JOIN [MyDatabase2].[MySchema2].[Table2] as B
   ON A.[Key] = B.[Key]
   )
  ;
  disconnect from odbc;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Aug 2016 20:02:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SQL-PassThru-Multiple-Database-Connections/m-p/292549#M60743</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2016-08-18T20:02:00Z</dc:date>
    </item>
    <item>
      <title>Re: SQL PassThru - Multiple Database Connections</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SQL-PassThru-Multiple-Database-Connections/m-p/292555#M60746</link>
      <description>&lt;P&gt;Thanks &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13976"&gt;@SASKiwi﻿&lt;/a&gt;.&amp;nbsp; Sorry for being dense, but with that connection string (noprompt="...") do you pass enough information that you completely avoid the need to pre-define an ODBC&amp;nbsp;data source (in ODBC administrator on Windows&amp;nbsp;or odbc.ini on linux)?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Okay re-reading the docs, it says NOPROMPT "specifies connection options for your data source&lt;STRONG&gt; or database&lt;/STRONG&gt;."&amp;nbsp; So that means with NOPROMPT I should be able to pass all the information needed to&amp;nbsp;connect to a database on a server, &lt;EM&gt;without first defining it as an ODBC data source&lt;/EM&gt;?&amp;nbsp; [guess that's the same question twice]&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So the next time someone says "Please pull some data from database X on server Y using account ReaderZ and PasswordZ " I should be able to do it myself from our SAS server, without asking the admin to define a new ODBC connection for me?&amp;nbsp; (Assuming I don't need to&amp;nbsp;register the database in metadata)&amp;nbsp; [Same question third time perhaps, but I'm excited ]&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That would make me sooo happy.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Aug 2016 20:23:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SQL-PassThru-Multiple-Database-Connections/m-p/292555#M60746</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2016-08-18T20:23:58Z</dc:date>
    </item>
    <item>
      <title>Re: SQL PassThru - Multiple Database Connections</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SQL-PassThru-Multiple-Database-Connections/m-p/292563#M60751</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/19879"&gt;@Quentin﻿&lt;/a&gt;&amp;nbsp;- Does your SAS server run on Windows or Unix? If on Windows then the NOPROMPT completely defines your SQL Server connection and nothing needs to be defined elsewhere. If you are on Unix then I think you are stuck with using ODBC.INI. Try a query like the one I posted anyway. I suspect it may not matter what database/schema you connect to initially as long as you use the 3-stage table strings to reference tables in other SQL Server databases.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Aug 2016 20:45:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SQL-PassThru-Multiple-Database-Connections/m-p/292563#M60751</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2016-08-18T20:45:48Z</dc:date>
    </item>
    <item>
      <title>Re: SQL PassThru - Multiple Database Connections</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SQL-PassThru-Multiple-Database-Connections/m-p/292588#M60764</link>
      <description>Thanks. Will play with it a bit. Our SAS server is Linux. But I have Windows PC SAS too. So will start by trying to get it to work on Windows, then will move on to Linux. &amp;nbsp;--Q.&amp;nbsp;&lt;BR /&gt;</description>
      <pubDate>Thu, 18 Aug 2016 21:45:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SQL-PassThru-Multiple-Database-Connections/m-p/292588#M60764</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2016-08-18T21:45:59Z</dc:date>
    </item>
  </channel>
</rss>

