<?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 pass through vs libname ODBC with unexpected results? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SQL-pass-through-vs-libname-ODBC-with-unexpected-results/m-p/705193#M216267</link>
    <description>&lt;P&gt;Sir&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp; &lt;STRONG&gt;BRILLIANT BRILLIANT BRILLIANT.!!!!!!!!!!!!! YES I AM SHOUTING. AGAIN- BRILLIANT!!!!!!!!!!!!&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's just unfair for Einsteins to be in SAS community. I I just can't thank you enough.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Okay, one follow from my team, Can you please give us a moment to enlighten to thoroughly understand the mechanics as what SQL pass through fetches in full while&amp;nbsp; the libname couldn't. I will just send this link to my team mates and share the knowledge once I could have the privilege of yet another response please.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;KUDOS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 10 Dec 2020 19:41:20 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2020-12-10T19:41:20Z</dc:date>
    <item>
      <title>SQL pass through vs libname ODBC with unexpected results?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SQL-pass-through-vs-libname-ODBC-with-unexpected-results/m-p/705155#M216252</link>
      <description>&lt;P&gt;SQL pass through vs libname ODBC with unexpected results? Requesting advise as to why, what and how to fix plz?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
/*Pass through*/
proc sql noprint;
connect to odbc(dsn=MSPBDE_PROD);
create table work.COVID_FB as 
select * from connection to odbc
     (select 
      a.LN_NO,
	  a._RowStatus,
	  a._EffectiveDate,
	  a._ExpirationDate,
	  a.FP_CREAT_DT,
	  a.FP_STAT_CD,
	  a.FP_STAT_DT,
	  a.FP_PROMISE_QT,
	  a.FP_PLAN_TY,
	  a.FP_LST_PR_DU_DT

      from MSPODS.bde.FORBEARANCE_PLAN for system_time ALL as a
   WHERE a._RowStatus NOT IN ('PD') AND a.FP_PLAN_TY in('90','91','92','93'));
quit;

proc sql;
 select count(LN_NO) as c, count(distinct LN_NO) as c1
 from COVID_FB;
quit;

RESULTS:
c	           c1
134289	34866
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Vs&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*Libname */
libname msp_ods odbc dsn=mspbde_prod qualifier=MSPODS schema=BDE;

data w;
 set msp_ods.FORBEARANCE_PLAN;
 WHERE _RowStatus NOT IN ('PD') AND FP_PLAN_TY in('90','91','92','93');
run;

proc sql;
 select count(LN_NO) as c
 from w;
quit;

RESULT:
c
34671
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;What's going on?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Dec 2020 18:13:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SQL-pass-through-vs-libname-ODBC-with-unexpected-results/m-p/705155#M216252</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-12-10T18:13:46Z</dc:date>
    </item>
    <item>
      <title>Re: SQL pass through vs libname ODBC with unexpected results?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SQL-pass-through-vs-libname-ODBC-with-unexpected-results/m-p/705165#M216257</link>
      <description>&lt;P&gt;How many records returned for Work.Covid_FB and&amp;nbsp; W?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;
      from MSPODS.bde.FORBEARANCE_PLAN for system_time ALL as a
   WHERE a._RowStatus NOT IN ('PD') AND a.FP_PLAN_TY in('90','91','92','93'));
quit;&lt;/LI-CODE&gt;
&lt;P&gt;I might guess that the pass through using "for system_time all" overrides a default behavior from the ODBC connection default.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Dec 2020 18:31:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SQL-pass-through-vs-libname-ODBC-with-unexpected-results/m-p/705165#M216257</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-12-10T18:31:28Z</dc:date>
    </item>
    <item>
      <title>Re: SQL pass through vs libname ODBC with unexpected results?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SQL-pass-through-vs-libname-ODBC-with-unexpected-results/m-p/705166#M216258</link>
      <description>&lt;P&gt;Do a PROC COMPARE on the two extracted datasets to see if you are starting with the same data.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Dec 2020 18:32:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SQL-pass-through-vs-libname-ODBC-with-unexpected-results/m-p/705166#M216258</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2020-12-10T18:32:52Z</dc:date>
    </item>
    <item>
      <title>Re: SQL pass through vs libname ODBC with unexpected results?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SQL-pass-through-vs-libname-ODBC-with-unexpected-results/m-p/705167#M216259</link>
      <description>&lt;TABLE width="172"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD colspan="2" width="172"&gt;&lt;STRONG&gt;passthrough results&lt;/STRONG&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="86"&gt;c&lt;/TD&gt;
&lt;TD width="86"&gt;c1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;134289&lt;/TD&gt;
&lt;TD&gt;34866&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD colspan="2"&gt;&lt;STRONG&gt;libname results&lt;/STRONG&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="86"&gt;c&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;34671&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
      <pubDate>Thu, 10 Dec 2020 18:33:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SQL-pass-through-vs-libname-ODBC-with-unexpected-results/m-p/705167#M216259</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-12-10T18:33:17Z</dc:date>
    </item>
    <item>
      <title>Re: SQL pass through vs libname ODBC with unexpected results?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SQL-pass-through-vs-libname-ODBC-with-unexpected-results/m-p/705169#M216261</link>
      <description>&lt;P&gt;What does this:&lt;/P&gt;
&lt;PRE&gt;for system_time ALL&lt;/PRE&gt;
&lt;P&gt;in the pass-through do?&lt;/P&gt;</description>
      <pubDate>Thu, 10 Dec 2020 18:37:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SQL-pass-through-vs-libname-ODBC-with-unexpected-results/m-p/705169#M216261</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-12-10T18:37:30Z</dc:date>
    </item>
    <item>
      <title>Re: SQL pass through vs libname ODBC with unexpected results?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SQL-pass-through-vs-libname-ODBC-with-unexpected-results/m-p/705180#M216264</link>
      <description>&lt;P&gt;Many thanks &lt;STRONG&gt;'Sir'*3&lt;/STRONG&gt; for quick responses.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm afraid I do not know SQL server proprietary language yet and I inherited from somebody here.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I googled this&amp;nbsp;&lt;A href="https://docs.microsoft.com/en-us/sql/relational-databases/tables/querying-data-in-a-system-versioned-temporal-table?view=sql-server-ver15" target="_blank" rel="noopener"&gt;https://docs.microsoft.com/en-us/sql/relational-databases/tables/querying-data-in-a-system-versioned-temporal-table?view=sql-server-ver15&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;to see what it means -&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;"If you search for non-current row versions only, we recommend you query the history table directly as this will yield the best query performance. Use&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;ALL&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;when you need to query current and historical data without any restrictions."&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If I am "comprehending correctly", all ln_no(loans) in forebearance table with its &lt;STRONG&gt;history&lt;/STRONG&gt; is what I am after. I am sure this would make sense to you.&amp;nbsp; I presume from the above definition the ALL keyword gives me everything. However, how to replicate the same with LIBNAME? Or is it some sort of a restricted snaps that libname engine cannot fetch while pass through could?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;For some reason, I am glad my mind told me check this. Had I just went with Libname results, I would had to face a huge escalation. Gosh, I am breathing still.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Dec 2020 18:57:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SQL-pass-through-vs-libname-ODBC-with-unexpected-results/m-p/705180#M216264</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-12-10T18:57:41Z</dc:date>
    </item>
    <item>
      <title>Re: SQL pass through vs libname ODBC with unexpected results?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SQL-pass-through-vs-libname-ODBC-with-unexpected-results/m-p/705182#M216265</link>
      <description>&lt;P&gt;Never used SQL server but for Teradata temporal tables we just set-up views that included the equivalent option for accessing the historical records.&amp;nbsp; So you might have a table or view named MYTABLE that shows the current state and than a view named MYTABLE_HISTORY that shows all records.&amp;nbsp; Then you can reference the MYTABLE_HISTORY view through your libref and see all records.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Dec 2020 19:20:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SQL-pass-through-vs-libname-ODBC-with-unexpected-results/m-p/705182#M216265</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-12-10T19:20:03Z</dc:date>
    </item>
    <item>
      <title>Re: SQL pass through vs libname ODBC with unexpected results?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SQL-pass-through-vs-libname-ODBC-with-unexpected-results/m-p/705193#M216267</link>
      <description>&lt;P&gt;Sir&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp; &lt;STRONG&gt;BRILLIANT BRILLIANT BRILLIANT.!!!!!!!!!!!!! YES I AM SHOUTING. AGAIN- BRILLIANT!!!!!!!!!!!!&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's just unfair for Einsteins to be in SAS community. I I just can't thank you enough.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Okay, one follow from my team, Can you please give us a moment to enlighten to thoroughly understand the mechanics as what SQL pass through fetches in full while&amp;nbsp; the libname couldn't. I will just send this link to my team mates and share the knowledge once I could have the privilege of yet another response please.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;KUDOS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Dec 2020 19:41:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SQL-pass-through-vs-libname-ODBC-with-unexpected-results/m-p/705193#M216267</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-12-10T19:41:20Z</dc:date>
    </item>
  </channel>
</rss>

