<?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: Updating a SQL table via ODBC from a SAS table in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Updating-a-SQL-table-via-ODBC-from-a-SAS-table/m-p/577419#M13206</link>
    <description>&lt;P&gt;Here is my updated code with errors:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;libname SQL odbc datasrc=myDSN schema=dbo;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc Sql;&lt;BR /&gt;&amp;nbsp;update SQL.EmailListingtest t1&lt;BR /&gt;&amp;nbsp;&amp;nbsp;set EmailList = (select EmailList&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;from SASemaillist1 t2&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;where t1.Team = t2.Team)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;,LastUpdateDt = (select LastUpdateDt&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;from SASemaillist1 t2&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;where t1.Team = t2.Team)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;where team in (select t2.team from SASemaillist1 t2);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am getting these errors:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR: Error binding parameters: [Microsoft][ODBC Driver 17 for SQL Server]Invalid precision value&lt;/P&gt;&lt;P&gt;ERROR: ROLLBACK issued due to errors for data set SQL.EmailListingtest.DATA.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 29 Jul 2019 15:59:55 GMT</pubDate>
    <dc:creator>zdeb15</dc:creator>
    <dc:date>2019-07-29T15:59:55Z</dc:date>
    <item>
      <title>Updating a SQL table via ODBC from a SAS table</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Updating-a-SQL-table-via-ODBC-from-a-SAS-table/m-p/576911#M13125</link>
      <description>&lt;P&gt;Hi all, There is a table in our data warehouse that contains an e-mail distribution group. I want to update that table from SAS ...Is there a way to update a SQL table from a SAS table?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;libname mylibref odbc datasrc=mydatasource schema=dbo;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc Sql;&lt;BR /&gt;Connect to odbc (datasrc=mydatasource);&lt;/P&gt;&lt;P&gt;update [db].dbo.sqltable t1&lt;BR /&gt;set EmailList = (select EmailList&lt;BR /&gt;from SASemaillist1 t2&lt;BR /&gt;where t1.Team = t2.Team)&lt;BR /&gt;where team in (select t2.team from SASemaillist1 t2);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;disconnect from odbc;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jul 2019 14:20:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Updating-a-SQL-table-via-ODBC-from-a-SAS-table/m-p/576911#M13125</guid>
      <dc:creator>zdeb15</dc:creator>
      <dc:date>2019-07-26T14:20:39Z</dc:date>
    </item>
    <item>
      <title>Re: Updating a SQL table via ODBC from a SAS table</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Updating-a-SQL-table-via-ODBC-from-a-SAS-table/m-p/576929#M13128</link>
      <description>&lt;P&gt;You're mixing explicit SQL and implicit SQL there. You cannot do that.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You need to find the SAS code that you need to run, not the SQL you're currently using and it should work directly from PROC EXPORT.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You cannot use explicit SQL here because it only passes your query to the server, not your SAS data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;libname mylibref odbc datasrc=mydatasource schema=dbo;

 

proc Sql;
&lt;FONT size="4" color="#FF0000"&gt;&lt;STRONG&gt;Connect to odbc (datasrc=mydatasource); *makes this explicit SQL;&lt;/STRONG&gt;&lt;/FONT&gt;

update [db].dbo.sqltable as t1
set EmailList = (select EmailList
from SASemaillist1 t2
where t1.Team = t2.Team)
where team in (select t2.team from SASemaillist1 t2);


disconnect from odbc;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instead your code should look like the following - note I don't think this is correct and don't know what the correct code should be, just pointing you in the right direction.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
update mylibref.sqltable as t1
set EmailList = (select EmailList
from SASemaillist1 t2
where t1.Team = t2.Team)
where team in (select t2.team from SASemaillist1 t2);&lt;BR /&gt;quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jul 2019 15:04:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Updating-a-SQL-table-via-ODBC-from-a-SAS-table/m-p/576929#M13128</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-07-26T15:04:36Z</dc:date>
    </item>
    <item>
      <title>Re: Updating a SQL table via ODBC from a SAS table</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Updating-a-SQL-table-via-ODBC-from-a-SAS-table/m-p/577419#M13206</link>
      <description>&lt;P&gt;Here is my updated code with errors:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;libname SQL odbc datasrc=myDSN schema=dbo;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc Sql;&lt;BR /&gt;&amp;nbsp;update SQL.EmailListingtest t1&lt;BR /&gt;&amp;nbsp;&amp;nbsp;set EmailList = (select EmailList&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;from SASemaillist1 t2&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;where t1.Team = t2.Team)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;,LastUpdateDt = (select LastUpdateDt&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;from SASemaillist1 t2&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;where t1.Team = t2.Team)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;where team in (select t2.team from SASemaillist1 t2);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am getting these errors:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR: Error binding parameters: [Microsoft][ODBC Driver 17 for SQL Server]Invalid precision value&lt;/P&gt;&lt;P&gt;ERROR: ROLLBACK issued due to errors for data set SQL.EmailListingtest.DATA.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jul 2019 15:59:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Updating-a-SQL-table-via-ODBC-from-a-SAS-table/m-p/577419#M13206</guid>
      <dc:creator>zdeb15</dc:creator>
      <dc:date>2019-07-29T15:59:55Z</dc:date>
    </item>
    <item>
      <title>Re: Updating a SQL table via ODBC from a SAS table</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Updating-a-SQL-table-via-ODBC-from-a-SAS-table/m-p/577420#M13207</link>
      <description>Pretty sure that's now a SQL update error, which I don't know how to resolve. I would suggest trying a simpler query to ensure that updates are occurring and then once you know it can be done, fine tuning your SQL query to get it working as desired.</description>
      <pubDate>Mon, 29 Jul 2019 16:04:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Updating-a-SQL-table-via-ODBC-from-a-SAS-table/m-p/577420#M13207</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-07-29T16:04:04Z</dc:date>
    </item>
  </channel>
</rss>

