<?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: update table in sql server management studio from SAS dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/update-table-in-sql-server-management-studio-from-SAS-dataset/m-p/235043#M43026</link>
    <description>&lt;P&gt;Hi ,&lt;/P&gt;
&lt;P&gt;Could you pls explain the code for option 2 . actually I have used below code but when i am using this its chaging teh date format&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;pls explain how to do it&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt; delete from sqldb.xy;&lt;BR /&gt; insert into sqldb.xy&lt;BR /&gt; select * from price.yz&lt;BR /&gt; ;&lt;BR /&gt; quit;&lt;/P&gt;</description>
    <pubDate>Tue, 17 Nov 2015 15:38:30 GMT</pubDate>
    <dc:creator>chennupriya</dc:creator>
    <dc:date>2015-11-17T15:38:30Z</dc:date>
    <item>
      <title>update table in sql server management studio from SAS dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/update-table-in-sql-server-management-studio-from-SAS-dataset/m-p/233449#M42630</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;I have a sas dataset finalxyz so its has data from aug2014 to aug2015 now and if i run next month it will have sep2015 records&lt;/P&gt;
&lt;P&gt;and using libname i have loaded that table into sql server but every month we get records for new months so there is a way that if i run sas code the table would get updated automatically with new records in sql ?. Can anyone pls help&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 06 Nov 2015 15:39:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/update-table-in-sql-server-management-studio-from-SAS-dataset/m-p/233449#M42630</guid>
      <dc:creator>chennupriya</dc:creator>
      <dc:date>2015-11-06T15:39:18Z</dc:date>
    </item>
    <item>
      <title>Re: update table in sql server management studio from SAS dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/update-table-in-sql-server-management-studio-from-SAS-dataset/m-p/233450#M42631</link>
      <description>Can you assume the old records won't have changed and you only need to upload the new records or the does the whole table need to be updated?&lt;BR /&gt;&lt;BR /&gt;Anyways look at the UPDATE statement in a Datastep. Assuming you have the correct permissions on the server you should be able to run an update automatically.</description>
      <pubDate>Fri, 06 Nov 2015 15:41:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/update-table-in-sql-server-management-studio-from-SAS-dataset/m-p/233450#M42631</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-11-06T15:41:42Z</dc:date>
    </item>
    <item>
      <title>Re: update table in sql server management studio from SAS dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/update-table-in-sql-server-management-studio-from-SAS-dataset/m-p/233458#M42634</link>
      <description>&lt;P&gt;in old records some amount fields get void and loan numbers may change and also we need to upload new records&lt;/P&gt;</description>
      <pubDate>Fri, 06 Nov 2015 15:53:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/update-table-in-sql-server-management-studio-from-SAS-dataset/m-p/233458#M42634</guid>
      <dc:creator>chennupriya</dc:creator>
      <dc:date>2015-11-06T15:53:48Z</dc:date>
    </item>
    <item>
      <title>Re: update table in sql server management studio from SAS dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/update-table-in-sql-server-management-studio-from-SAS-dataset/m-p/233464#M42636</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sounds like an UPDATE to me:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/basess/58133/HTML/default/viewer.htm#a001329151.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/basess/58133/HTML/default/viewer.htm#a001329151.htm&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Nov 2015 16:03:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/update-table-in-sql-server-management-studio-from-SAS-dataset/m-p/233464#M42636</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-11-06T16:03:43Z</dc:date>
    </item>
    <item>
      <title>Re: update table in sql server management studio from SAS dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/update-table-in-sql-server-management-studio-from-SAS-dataset/m-p/233471#M42638</link>
      <description>&lt;P&gt;how to write a code so that it will update the sql table in sql server when i run sas code both sas dataset and sql table will have same variables but in sas dataset which i run everymonth will have any changes in old records and new records&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;can u pls let me know how to write the code&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 06 Nov 2015 16:22:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/update-table-in-sql-server-management-studio-from-SAS-dataset/m-p/233471#M42638</guid>
      <dc:creator>chennupriya</dc:creator>
      <dc:date>2015-11-06T16:22:29Z</dc:date>
    </item>
    <item>
      <title>Re: update table in sql server management studio from SAS dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/update-table-in-sql-server-management-studio-from-SAS-dataset/m-p/233479#M42640</link>
      <description>&lt;P&gt;&lt;A href="http://analytics.ncsu.edu/sesug/2001/P-354.pdf" target="_blank"&gt;http://analytics.ncsu.edu/sesug/2001/P-354.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is a paper that goes over some of the options.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In addition to Update, there's Modify and a straightforward Merge.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Nov 2015 16:40:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/update-table-in-sql-server-management-studio-from-SAS-dataset/m-p/233479#M42640</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-11-06T16:40:19Z</dc:date>
    </item>
    <item>
      <title>Re: update table in sql server management studio from SAS dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/update-table-in-sql-server-management-studio-from-SAS-dataset/m-p/233594#M42671</link>
      <description>&lt;P&gt;You need to update data already loaded and you need to insert new records not loaded yet. Your source is a SAS data set your target is a SQL Server table.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What you're after is an "upsert". There are multiple way of how to do this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Option1:&lt;/P&gt;
&lt;P&gt;Use the MODIFY statement in a SAS dataset&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Option2:&lt;/P&gt;
&lt;P&gt;Split up your data. Run an UPDATE for data previously loaded (I would use the SQL UPDATE), use a Proc Append for new data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Option3:&lt;/P&gt;
&lt;P&gt;- Load your data into a staging table (just an empty table which you create on the server).&lt;/P&gt;
&lt;P&gt;- Load all data into this staging table using Proc Append (eventually with bulk load options),&lt;/P&gt;
&lt;P&gt;- then via pass-through SQL execute a MERGE statement&amp;nbsp;&lt;A href="https://technet.microsoft.com/en-us/library/bb522522(v=sql.105).aspx" target="_blank"&gt;https://technet.microsoft.com/en-us/library/bb522522(v=sql.105).aspx&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;- truncate your staging table (or leave the data there for "debugging" and only truncate it the next time before you load new data)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Even though it sounds a bit more complicated I personally would go for Option 3 if&amp;nbsp;the data volumes get into the millions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 07 Nov 2015 02:20:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/update-table-in-sql-server-management-studio-from-SAS-dataset/m-p/233594#M42671</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2015-11-07T02:20:00Z</dc:date>
    </item>
    <item>
      <title>Re: update table in sql server management studio from SAS dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/update-table-in-sql-server-management-studio-from-SAS-dataset/m-p/235043#M43026</link>
      <description>&lt;P&gt;Hi ,&lt;/P&gt;
&lt;P&gt;Could you pls explain the code for option 2 . actually I have used below code but when i am using this its chaging teh date format&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;pls explain how to do it&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt; delete from sqldb.xy;&lt;BR /&gt; insert into sqldb.xy&lt;BR /&gt; select * from price.yz&lt;BR /&gt; ;&lt;BR /&gt; quit;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Nov 2015 15:38:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/update-table-in-sql-server-management-studio-from-SAS-dataset/m-p/235043#M43026</guid>
      <dc:creator>chennupriya</dc:creator>
      <dc:date>2015-11-17T15:38:30Z</dc:date>
    </item>
    <item>
      <title>Re: update table in sql server management studio from SAS dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/update-table-in-sql-server-management-studio-from-SAS-dataset/m-p/235126#M43044</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Nov 2015 20:13:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/update-table-in-sql-server-management-studio-from-SAS-dataset/m-p/235126#M43044</guid>
      <dc:creator>chennupriya</dc:creator>
      <dc:date>2015-11-17T20:13:42Z</dc:date>
    </item>
    <item>
      <title>Re: update table in sql server management studio from SAS dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/update-table-in-sql-server-management-studio-from-SAS-dataset/m-p/235133#M43046</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11383"&gt;@chennupriya﻿&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;The "changing the date format" is another issue and you will have to explain a bit more what you have and what you get - and what you would expect to get.&lt;/P&gt;
&lt;P&gt;For the SAS/Access engines to get it right best use for the source SAS variables containing date values:&amp;nbsp;date9., datetime20.,&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/acreldb/68028/HTML/default/viewer.htm#n13gtugcxgdqstn1pooivt622n4q.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/acreldb/68028/HTML/default/viewer.htm#n13gtugcxgdqstn1pooivt622n4q.htm&lt;/A&gt; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As for your code:&lt;/P&gt;
&lt;P&gt;If all you need is an exact copy of the current data set from SAS in SQL Server then depending on data volumes your approach is eventually very o.k. Does this run within reasonable time?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Normally a SQL DELETE is a slow operation and if it's about removing all data then a TRUNCATE statement (executed in a Pass-through block) is much faster.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.techonthenet.com/sql_server/truncate.php" target="_blank"&gt;http://www.techonthenet.com/sql_server/truncate.php&amp;nbsp;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/acreldb/68028/HTML/default/viewer.htm#p09s44hpea09stn1puyx1l5vcwwt.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/acreldb/68028/HTML/default/viewer.htm#p09s44hpea09stn1puyx1l5vcwwt.htm&amp;nbsp;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;(do you use the SAS Access to ODBC or &lt;SPAN&gt;SAS Access to &lt;/SPAN&gt;SQL Server?)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For the insert:&amp;nbsp;Instead of the SQL Insert you could also use Proc Append&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc append base=sqldb.xy data=price.yz;
run;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;There are also a few options you might want to look up if useful for you like:&lt;/P&gt;
&lt;P&gt;dbcommit&lt;/P&gt;
&lt;P&gt;insertbuff&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/acreldb/68028/HTML/default/viewer.htm#n009p6849p6ynzn1t76wskgry4ob.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/acreldb/68028/HTML/default/viewer.htm#n009p6849p6ynzn1t76wskgry4ob.htm&amp;nbsp;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/bidsag/68193/HTML/default/viewer.htm#p1icta556r8bacn1ns9kvvnxd4iv.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/bidsag/68193/HTML/default/viewer.htm#p1icta556r8bacn1ns9kvvnxd4iv.htm&amp;nbsp;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Nov 2015 21:55:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/update-table-in-sql-server-management-studio-from-SAS-dataset/m-p/235133#M43046</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2015-11-18T21:55:27Z</dc:date>
    </item>
  </channel>
</rss>

