<?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: SAS query to SQL Server DB returns duplicate ID in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/SAS-query-to-SQL-Server-DB-returns-duplicate-ID/m-p/330485#M9716</link>
    <description>&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just a very wild guess, have a look at READ_ISOLATION_LEVEL option &lt;A href="http://support.sas.com/documentation/cdl/en/acreldb/69580/HTML/default/viewer.htm#n0xth6czn6guxrn13z0b2vyer8dt.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/acreldb/69580/HTML/default/viewer.htm#n0xth6czn6guxrn13z0b2vyer8dt.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bruno&lt;/P&gt;</description>
    <pubDate>Tue, 07 Feb 2017 15:04:34 GMT</pubDate>
    <dc:creator>BrunoMueller</dc:creator>
    <dc:date>2017-02-07T15:04:34Z</dc:date>
    <item>
      <title>SAS query to SQL Server DB returns duplicate ID</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/SAS-query-to-SQL-Server-DB-returns-duplicate-ID/m-p/330439#M9711</link>
      <description>&lt;P&gt;We have a number of SAS DI jobs that query MS SQL Server (2008) via OLE DB. &amp;nbsp;I recently noticed that the result was returning duplicates from a field with a primary key contraint - so this shouldn't be possible. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;On further inspection I can recreate the error from the ETL job that is returning two fields from the source table. &amp;nbsp;However, these fields are being processed in SAS (number &amp;gt;&amp;gt; character and a data extraction) - so no 'raw' data is returned from the SQL query. &amp;nbsp;It appears that the duplicate primary keys are coming through because the source table is being modified by the source system during the SAS query execution (as shown by a record change datetime field). &amp;nbsp;I can recreate this error over and over again in a simple macro.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I change the macro to first - Select * from sourceTable - and then perfrom the SAS conversions to return the two fields (see above) no duplicate primary keys come through.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So it would appear that running a SQL statement that does SAS specific conversions vs. running a SQL statement that (as far I know) uses SQL pass-thru - ends up returning duplicates even through there is a contraint on the source table. &amp;nbsp;So SAS must not be locking the table (or getting a lock from the DMBS).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is anyone able to point me at some technical details that cover this issue and why it occurs. &amp;nbsp;The issue is a little perplexing in that I have had to investigate something that I've been told cannot occur. &amp;nbsp;Furthermore, this now appears to be a SAS specific issue when we have blamed the source system (MS SQL) because of being told that SAS would get a lock on the table and the cause cannot be a SAS issue.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this makes sense but happy to elaborate further if more information is needed.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Feb 2017 11:04:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/SAS-query-to-SQL-Server-DB-returns-duplicate-ID/m-p/330439#M9711</guid>
      <dc:creator>max00d</dc:creator>
      <dc:date>2017-02-07T11:04:09Z</dc:date>
    </item>
    <item>
      <title>Re: SAS query to SQL Server DB returns duplicate ID</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/SAS-query-to-SQL-Server-DB-returns-duplicate-ID/m-p/330446#M9712</link>
      <description>&lt;P&gt;We're using a completely different RDBMS (UDB or DB/2), but we run our extracts from snapshots, so we always get consistent states.&lt;/P&gt;
&lt;P&gt;Freezing a snapshot is necessary to prevent not only inconsistencies&amp;nbsp;&lt;U&gt;in&lt;/U&gt; tables, but also&amp;nbsp;&lt;U&gt;between&lt;/U&gt; them. Consider running critical extracts during a time window where the DB is stopped, if you can't create snapshots.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Feb 2017 11:57:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/SAS-query-to-SQL-Server-DB-returns-duplicate-ID/m-p/330446#M9712</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-02-07T11:57:04Z</dc:date>
    </item>
    <item>
      <title>Re: SAS query to SQL Server DB returns duplicate ID</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/SAS-query-to-SQL-Server-DB-returns-duplicate-ID/m-p/330447#M9713</link>
      <description>Agree that you have a basic integrity issue in your extract logic.&lt;BR /&gt;But regardless it sounds odd that a record will duplicate during a select because of update...Perhaps you should involve SAS tech support to dig into this...?</description>
      <pubDate>Tue, 07 Feb 2017 12:33:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/SAS-query-to-SQL-Server-DB-returns-duplicate-ID/m-p/330447#M9713</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2017-02-07T12:33:44Z</dc:date>
    </item>
    <item>
      <title>Re: SAS query to SQL Server DB returns duplicate ID</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/SAS-query-to-SQL-Server-DB-returns-duplicate-ID/m-p/330485#M9716</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just a very wild guess, have a look at READ_ISOLATION_LEVEL option &lt;A href="http://support.sas.com/documentation/cdl/en/acreldb/69580/HTML/default/viewer.htm#n0xth6czn6guxrn13z0b2vyer8dt.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/acreldb/69580/HTML/default/viewer.htm#n0xth6czn6guxrn13z0b2vyer8dt.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bruno&lt;/P&gt;</description>
      <pubDate>Tue, 07 Feb 2017 15:04:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/SAS-query-to-SQL-Server-DB-returns-duplicate-ID/m-p/330485#M9716</guid>
      <dc:creator>BrunoMueller</dc:creator>
      <dc:date>2017-02-07T15:04:34Z</dc:date>
    </item>
  </channel>
</rss>

