<?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 a column in SQL server table from SAS dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Update-a-column-in-SQL-server-table-from-SAS-dataset/m-p/740376#M231272</link>
    <description>&lt;P&gt;When I overwrite SQL table with SAS table I do as in the code below.&lt;/P&gt;
&lt;P&gt;In my current task though, SQL people do not want SQL table to be overwritten. Therefore, I can only update values in one column. The table in SQL is a control table which tells SAS which processes to be executed. It has a column - SAS_Run_Flag=0. When SAS finishes without error,&amp;nbsp;&amp;nbsp;SAS_Run_Flag changes to 1 in SAS temporary table. Then&amp;nbsp;SAS_Run_Flag in SQL has to be updated with values from SAS temp table. Hope it makes sense.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Code for SQL table over-write:&lt;/P&gt;
&lt;P&gt;LIBNAME DSAS01 pcfiles server=localhost port=9621 dsn=SAS_dSAS01 user=SASConnector&amp;nbsp;password="";&lt;BR /&gt;PROC SQL;&lt;BR /&gt;CONNECT to pcfiles as myconn (server=localhost port=9621 dsn=SAS_dSAS01_&amp;amp;dsn_dst user=SASConnector&amp;nbsp;password="");&lt;/P&gt;
&lt;P&gt;SELECT * from connection to myconn&lt;BR /&gt;( &lt;BR /&gt;IF OBJECT_ID(%str(%')&amp;amp;OutFile%str(%'), 'U') IS NOT NULL&lt;BR /&gt;DROP TABLE &amp;amp;OutFile;&lt;BR /&gt;);&lt;BR /&gt;QUIT;&lt;BR /&gt;*-------------| Write the updated table |-----------------;&lt;BR /&gt;DATA dsas01.&amp;amp;OutFile;&lt;BR /&gt;SET &amp;amp;OutFile;&lt;BR /&gt;RUN;&lt;/P&gt;</description>
    <pubDate>Tue, 11 May 2021 05:06:12 GMT</pubDate>
    <dc:creator>VSht</dc:creator>
    <dc:date>2021-05-11T05:06:12Z</dc:date>
    <item>
      <title>Update a column in SQL server table from SAS dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Update-a-column-in-SQL-server-table-from-SAS-dataset/m-p/740372#M231269</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I've got a table in SQL server and a table in SAS, with the same structure and a unique row identifier. I need to update a column in SQL table with the values from SAS table. Can it be done from SAS? I do not have ODBC or Access, but use PC Files for the SAS-SQL connection. Any help will be greatly appreciated.&lt;/P&gt;</description>
      <pubDate>Tue, 11 May 2021 04:41:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Update-a-column-in-SQL-server-table-from-SAS-dataset/m-p/740372#M231269</guid>
      <dc:creator>VSht</dc:creator>
      <dc:date>2021-05-11T04:41:20Z</dc:date>
    </item>
    <item>
      <title>Re: Update a column in SQL server table from SAS dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Update-a-column-in-SQL-server-table-from-SAS-dataset/m-p/740373#M231270</link>
      <description>&lt;P&gt;Can you post a code example of how you are accessing SQL Server via the SAS PC Files Server?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are able to load an SQL Server temporary table from SAS then you could run an SQL Server script to update from that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If that isn't an option you could write your SAS data to a delimited flat file and then have&amp;nbsp;an SQL Server script upload that.&lt;/P&gt;</description>
      <pubDate>Tue, 11 May 2021 04:51:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Update-a-column-in-SQL-server-table-from-SAS-dataset/m-p/740373#M231270</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2021-05-11T04:51:45Z</dc:date>
    </item>
    <item>
      <title>Re: Update a column in SQL server table from SAS dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Update-a-column-in-SQL-server-table-from-SAS-dataset/m-p/740376#M231272</link>
      <description>&lt;P&gt;When I overwrite SQL table with SAS table I do as in the code below.&lt;/P&gt;
&lt;P&gt;In my current task though, SQL people do not want SQL table to be overwritten. Therefore, I can only update values in one column. The table in SQL is a control table which tells SAS which processes to be executed. It has a column - SAS_Run_Flag=0. When SAS finishes without error,&amp;nbsp;&amp;nbsp;SAS_Run_Flag changes to 1 in SAS temporary table. Then&amp;nbsp;SAS_Run_Flag in SQL has to be updated with values from SAS temp table. Hope it makes sense.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Code for SQL table over-write:&lt;/P&gt;
&lt;P&gt;LIBNAME DSAS01 pcfiles server=localhost port=9621 dsn=SAS_dSAS01 user=SASConnector&amp;nbsp;password="";&lt;BR /&gt;PROC SQL;&lt;BR /&gt;CONNECT to pcfiles as myconn (server=localhost port=9621 dsn=SAS_dSAS01_&amp;amp;dsn_dst user=SASConnector&amp;nbsp;password="");&lt;/P&gt;
&lt;P&gt;SELECT * from connection to myconn&lt;BR /&gt;( &lt;BR /&gt;IF OBJECT_ID(%str(%')&amp;amp;OutFile%str(%'), 'U') IS NOT NULL&lt;BR /&gt;DROP TABLE &amp;amp;OutFile;&lt;BR /&gt;);&lt;BR /&gt;QUIT;&lt;BR /&gt;*-------------| Write the updated table |-----------------;&lt;BR /&gt;DATA dsas01.&amp;amp;OutFile;&lt;BR /&gt;SET &amp;amp;OutFile;&lt;BR /&gt;RUN;&lt;/P&gt;</description>
      <pubDate>Tue, 11 May 2021 05:06:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Update-a-column-in-SQL-server-table-from-SAS-dataset/m-p/740376#M231272</guid>
      <dc:creator>VSht</dc:creator>
      <dc:date>2021-05-11T05:06:12Z</dc:date>
    </item>
    <item>
      <title>Re: Update a column in SQL server table from SAS dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Update-a-column-in-SQL-server-table-from-SAS-dataset/m-p/741792#M231944</link>
      <description>&lt;P class="cs2654ae3a"&gt;&lt;FONT face="courier new,courier" size="4"&gt;&lt;SPAN class="csedbfcf261"&gt;&lt;SPAN style="font-size: 8.0pt;"&gt;libname sqlpcf pcfiles dsn="sqlpcf" user="....." password="....";&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class="cs2654ae3a"&gt;&lt;FONT face="courier new,courier" size="4"&gt;&lt;SPAN class="csedbfcf261"&gt;&lt;SPAN style="font-size: 8.0pt;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="courier new,courier" size="4"&gt;&lt;SPAN class="csedbfcf261"&gt;&lt;SPAN style="font-size: 8.0pt;"&gt;proc sql;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class="cs2654ae3a"&gt;&lt;FONT face="courier new,courier" size="4"&gt;&lt;SPAN class="csedbfcf261"&gt;&lt;SPAN style="font-size: 8.0pt;"&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;connect using sqlpcf;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class="cs2654ae3a"&gt;&lt;FONT face="courier new,courier" size="4"&gt;&lt;SPAN class="csedbfcf261"&gt;&lt;SPAN style="font-size: 8.0pt;"&gt;&amp;nbsp; &amp;nbsp; /* Microsoft SQL Server T-SQL syntax goes inside the () characters */&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class="cs2654ae3a"&gt;&lt;FONT face="courier new,courier" size="4"&gt;&lt;SPAN class="csedbfcf261"&gt;&lt;SPAN style="font-size: 8.0pt;"&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;execute (&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class="cs2654ae3a"&gt;&lt;FONT face="courier new,courier" size="4"&gt;&lt;SPAN class="csedbfcf261"&gt;&lt;SPAN style="font-size: 8.0pt;"&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;EXEC dbo.uspGetEmployeeManagers 6&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class="cs2654ae3a"&gt;&lt;FONT face="courier new,courier" size="4"&gt;&lt;SPAN class="csedbfcf261"&gt;&lt;SPAN style="font-size: 8.0pt;"&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;) by sqlpcf;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class="cs2654ae3a"&gt;&lt;FONT face="courier new,courier" size="4"&gt;&lt;SPAN class="csedbfcf261"&gt;&lt;SPAN style="font-size: 8.0pt;"&gt;quit;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class="cs2654ae3a"&gt;&lt;SPAN class="csedbfcf261"&gt;&lt;SPAN style="font-size: 8.0pt;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 16 May 2021 23:09:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Update-a-column-in-SQL-server-table-from-SAS-dataset/m-p/741792#M231944</guid>
      <dc:creator>VSht</dc:creator>
      <dc:date>2021-05-16T23:09:37Z</dc:date>
    </item>
  </channel>
</rss>

