<?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: Capturing Counts from destination SQL Server Database in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Capturing-Counts-from-destination-SQL-Server-Database/m-p/227372#M5482</link>
    <description>&lt;P&gt;Thank you as it was all timing so the sleep gave the SQL Server enough time to return the correct value.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I also tweeked the insert and commit buffer to lower numbers.&lt;/P&gt;
&lt;P&gt;Now it is capturing the correct value.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Much appreciated.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jonathan&lt;/P&gt;</description>
    <pubDate>Sat, 26 Sep 2015 00:17:05 GMT</pubDate>
    <dc:creator>jdmarshg</dc:creator>
    <dc:date>2015-09-26T00:17:05Z</dc:date>
    <item>
      <title>Capturing Counts from destination SQL Server Database</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Capturing-Counts-from-destination-SQL-Server-Database/m-p/226805#M5427</link>
      <description>&lt;P&gt;Hello everyone I'm using SAS DI Studio.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;User written code captures counts form a SQL Server database while looping through files.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;During the first loop for some reason I'm getting a count of 0 after data is loaded to a table.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It seems as if the count is capturing the state of the table before it is completed.&lt;/P&gt;
&lt;P&gt;Is there a way to pause between before running a proc sql statement?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS is installed on Linux.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any insight would be greatly appreciated as this is very frustrating as to why when I run the SAS base code within the code editor i get the proper count back but the package for some reason returns 0.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Jonathan&lt;/P&gt;
&lt;P&gt;Jon&lt;/P&gt;</description>
      <pubDate>Tue, 22 Sep 2015 20:26:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Capturing-Counts-from-destination-SQL-Server-Database/m-p/226805#M5427</guid>
      <dc:creator>jdmarshg</dc:creator>
      <dc:date>2015-09-22T20:26:21Z</dc:date>
    </item>
    <item>
      <title>Re: Capturing Counts from destination SQL Server Database</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Capturing-Counts-from-destination-SQL-Server-Database/m-p/226817#M5430</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This sounds like a mysterious&amp;nbsp;problem. My first thought is that you might consider tweaking "insertbuff" and "dbcommit" parameters&amp;nbsp;to a&amp;nbsp;tiny value (see &lt;STRONG&gt;tests 1&lt;/STRONG&gt;, &lt;STRONG&gt;2&lt;/STRONG&gt; and &lt;STRONG&gt;3&lt;/STRONG&gt;). This is not a good long-term solution (because it hurts performance), but it might get you closer to pinpointing whether the problem is perhaps due to certain kinds of concurrency.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Test 4&lt;/STRONG&gt; (sleeping for 10 seconds) would be an unusual coding technique, but it does address your desire to "pause" the program.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* TEST 1 - decrease insertbuff and dbcommit to a very small value */ 
LIBNAME MSSQL sqlsvr user=myusr1 password=mypwd1 insertbuff=50 dbcommit=50;
PROC SQL;
  INSERT INTO MSSQL.test_table
  SELECT * 
  FROM dataset_with_lots_of_rows;

  SELECT 'test1', COUNT(*) FROM MSSQL.test_table;
QUIT;


/* TEST 2 - same as test 1, but move the count to a separate PROC SQL statement */ 
PROC SQL;
  INSERT INTO MSSQL.test_table
  SELECT * 
  FROM dataset_with_lots_of_rows;
QUIT;

PROC SQL;
  SELECT 'test2', COUNT(*) FROM MSSQL.test_table;
QUIT;


/* TEST 3 - see if PROC APPEND produces makes a difference */ 
PROC APPEND BASE=MSSQL.test_table DATA=dataset_with_lots_of_rows; RUN;

PROC SQL;
  SELECT 'test3', COUNT(*) FROM MSSQL.test_table;
QUIT;


/* TEST 4 - introduce 10 seconds of sleep */ 
PROC SQL;
  INSERT INTO MSSQL.test_table
  SELECT * 
  FROM dataset_with_lots_of_rows;
QUIT;

DATA work.sleep_briefly(DROP=zzz);
    %LET the_time = %SYSFUNC(TIME(),TIME.);
    SYSECHO "Sleeping for 10 seconds at ... &amp;amp;the_time";
    zzz = sleep(10,1); /* sleep 10 seconds; 1 means use seconds */
RUN;

PROC SQL;
  SELECT 'test4', COUNT(*) FROM MSSQL.test_table;
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;Test 5&lt;/STRONG&gt; is a last resort because committing one row at a time will really hurt performance. &lt;STRONG&gt;Test 6&lt;/STRONG&gt; is something to&amp;nbsp;try if you have pinpointed which of the tests produce desirable results, at which point, you can tweak dbcommit and insertbuff to restore database performance to levels&amp;nbsp;that you can live with.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* TEST 5 - if the problem persists, try even smaller values and add INSERT_SQL=NO */
LIBNAME MSSQL sqlsvr user=myusr1 password=mypwd1 insertbuff=1 dbcommit=1 INSERT_SQL=NO;
/* repeat tests 1 to 4 and see what happens */


/* TEST 6 - increase insertbuff and dbcommit values that will restore decent 
   performance and see if problem still persists with larger values; 
   make sure insertbuff is a value less than dbcommit */
LIBNAME MSSQL sqlsvr user=myusr1 password=mypwd1 insertbuff=100 dbcommit=1000;
/* repeat tests 1 to 4 and see what happens */&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Would love to hear feedback as to whether&amp;nbsp;any of&amp;nbsp;these techniques&amp;nbsp;worked!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Sep 2015 21:33:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Capturing-Counts-from-destination-SQL-Server-Database/m-p/226817#M5430</guid>
      <dc:creator>hbi</dc:creator>
      <dc:date>2015-09-22T21:33:30Z</dc:date>
    </item>
    <item>
      <title>Re: Capturing Counts from destination SQL Server Database</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Capturing-Counts-from-destination-SQL-Server-Database/m-p/227372#M5482</link>
      <description>&lt;P&gt;Thank you as it was all timing so the sleep gave the SQL Server enough time to return the correct value.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I also tweeked the insert and commit buffer to lower numbers.&lt;/P&gt;
&lt;P&gt;Now it is capturing the correct value.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Much appreciated.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jonathan&lt;/P&gt;</description>
      <pubDate>Sat, 26 Sep 2015 00:17:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Capturing-Counts-from-destination-SQL-Server-Database/m-p/227372#M5482</guid>
      <dc:creator>jdmarshg</dc:creator>
      <dc:date>2015-09-26T00:17:05Z</dc:date>
    </item>
  </channel>
</rss>

