<?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: Create a temp table in SQL Server from SAS work table via SAS explicit pass through in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Create-a-temp-table-in-SQL-Server-from-SAS-work-table-via-SAS/m-p/743428#M232765</link>
    <description>&lt;P&gt;If &amp;amp;_INPUT refers to a SAS WORK table then your program won't work. Any SQL running inside an EXECUTE statement runs entirely on SQL Server and it knows nothing about SAS tables. Creating SQL Server temporary tables is best done using a SAS LIBNAME using the SQLSRVR engine. This post shows one way:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-to-populate-temp-table-with-SAS-dataset/td-p/171226&amp;nbsp;&amp;nbsp;" target="_blank" rel="noopener"&gt;https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-to-populate-temp-table-with-SAS-dataset/td-p/171226&amp;nbsp;&amp;nbsp;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This doc describes the general approach:&amp;nbsp;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/acreldb/n0irpkyp22l7vzn1il9lx6f4wmx9.htm" target="_blank"&gt;https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/acreldb/n0irpkyp22l7vzn1il9lx6f4wmx9.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 24 May 2021 20:29:39 GMT</pubDate>
    <dc:creator>SASKiwi</dc:creator>
    <dc:date>2021-05-24T20:29:39Z</dc:date>
    <item>
      <title>Create a temp table in SQL Server from SAS work table via SAS explicit pass through</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-temp-table-in-SQL-Server-from-SAS-work-table-via-SAS/m-p/743384#M232733</link>
      <description>&lt;P&gt;I would like to how to create a temp table in SQL Server by reading data from SAS work table via SAS explicit pass through&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;May I know what is the isue with INTO and&amp;nbsp;FROM &amp;nbsp;in code below?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Proc sql noprint;
    Connect to SQLSVR (DATAsrc=&amp;amp;DATA. AUTHDOMAIN="XXXXX." dbMax_text=32767);
    Execute( 
        Select * 
             1 as Version
            ,1 as delivery
            ,'' as data
            ,'' as Location
            ,'MASTER' as tableName
            ,Count(*) as numberOfRecords                          
            into: #temp%trim(&amp;amp;unique_num.)                   

        From &amp;amp;_INPUT.
            Group by Version,data,location;
    ) by SQLSVR;
    Disconnect from SQLSVR;
Quit;&lt;/PRE&gt;
&lt;P&gt;Error:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;ERROR: CLI execute error: [SAS][ODBC SQL Server Wire Protocol driver][Microsoft SQL Server]Incorrect syntax near ':'. : [SAS][ODBC 
       SQL Server Wire Protocol driver][Microsoft SQL Server]Executing SQL directly; no cursor.&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;Any help to resolve the error?&lt;/P&gt;</description>
      <pubDate>Mon, 24 May 2021 17:59:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-temp-table-in-SQL-Server-from-SAS-work-table-via-SAS/m-p/743384#M232733</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2021-05-24T17:59:12Z</dc:date>
    </item>
    <item>
      <title>Re: Create a temp table in SQL Server from SAS work table via SAS explicit pass through</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-temp-table-in-SQL-Server-from-SAS-work-table-via-SAS/m-p/743417#M232756</link>
      <description>&lt;P&gt;Please have a look here.&amp;nbsp;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/acreldb/p0he4t6yjfmkhpn16qrf0cdhllu6.htm#p1670uazqoglsvn1iywvcd6pv8d4" target="_blank"&gt;https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/acreldb/p0he4t6yjfmkhpn16qrf0cdhllu6.htm#p1670uazqoglsvn1iywvcd6pv8d4&lt;/A&gt;&amp;nbsp;&lt;BR /&gt;The example should solve your issue.&lt;/P&gt;</description>
      <pubDate>Mon, 24 May 2021 18:58:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-temp-table-in-SQL-Server-from-SAS-work-table-via-SAS/m-p/743417#M232756</guid>
      <dc:creator>Sajid01</dc:creator>
      <dc:date>2021-05-24T18:58:18Z</dc:date>
    </item>
    <item>
      <title>Re: Create a temp table in SQL Server from SAS work table via SAS explicit pass through</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-temp-table-in-SQL-Server-from-SAS-work-table-via-SAS/m-p/743428#M232765</link>
      <description>&lt;P&gt;If &amp;amp;_INPUT refers to a SAS WORK table then your program won't work. Any SQL running inside an EXECUTE statement runs entirely on SQL Server and it knows nothing about SAS tables. Creating SQL Server temporary tables is best done using a SAS LIBNAME using the SQLSRVR engine. This post shows one way:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-to-populate-temp-table-with-SAS-dataset/td-p/171226&amp;nbsp;&amp;nbsp;" target="_blank" rel="noopener"&gt;https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-to-populate-temp-table-with-SAS-dataset/td-p/171226&amp;nbsp;&amp;nbsp;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This doc describes the general approach:&amp;nbsp;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/acreldb/n0irpkyp22l7vzn1il9lx6f4wmx9.htm" target="_blank"&gt;https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/acreldb/n0irpkyp22l7vzn1il9lx6f4wmx9.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 May 2021 20:29:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-temp-table-in-SQL-Server-from-SAS-work-table-via-SAS/m-p/743428#M232765</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2021-05-24T20:29:39Z</dc:date>
    </item>
    <item>
      <title>Re: Create a temp table in SQL Server from SAS work table via SAS explicit pass through</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-temp-table-in-SQL-Server-from-SAS-work-table-via-SAS/m-p/743452#M232779</link>
      <description>How to create a temp table in SQL Server using explicit pass through ?&lt;BR /&gt;</description>
      <pubDate>Tue, 25 May 2021 01:56:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-temp-table-in-SQL-Server-from-SAS-work-table-via-SAS/m-p/743452#M232779</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2021-05-25T01:56:06Z</dc:date>
    </item>
    <item>
      <title>Re: Create a temp table in SQL Server from SAS work table via SAS explicit pass through</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-temp-table-in-SQL-Server-from-SAS-work-table-via-SAS/m-p/743472#M232789</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13976"&gt;@SASKiwi&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/131732"&gt;@Sajid01&lt;/a&gt;&amp;nbsp;Can't we create a temp table in SQL Server from SAS work table via SAS explicit pass through instead of using libname?&lt;/P&gt;</description>
      <pubDate>Tue, 25 May 2021 05:03:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-temp-table-in-SQL-Server-from-SAS-work-table-via-SAS/m-p/743472#M232789</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2021-05-25T05:03:17Z</dc:date>
    </item>
    <item>
      <title>Re: Create a temp table in SQL Server from SAS work table via SAS explicit pass through</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-temp-table-in-SQL-Server-from-SAS-work-table-via-SAS/m-p/743491#M232797</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/292396"&gt;@David_Billa&lt;/a&gt;&amp;nbsp; - Not possible unless your SAS program generates a bunch of SQL insert statements, one for each row you want to add - it's not a sensible solution. Using a LIBNAME statement and a PROC APPEND or SAS SQL is far preferrable.&lt;/P&gt;</description>
      <pubDate>Tue, 25 May 2021 06:46:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-temp-table-in-SQL-Server-from-SAS-work-table-via-SAS/m-p/743491#M232797</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2021-05-25T06:46:45Z</dc:date>
    </item>
    <item>
      <title>Re: Create a temp table in SQL Server from SAS work table via SAS explicit pass through</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-temp-table-in-SQL-Server-from-SAS-work-table-via-SAS/m-p/743495#M232800</link>
      <description>Any examples to do it using SAS SQL as you mentioned?&lt;BR /&gt;</description>
      <pubDate>Tue, 25 May 2021 07:08:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-temp-table-in-SQL-Server-from-SAS-work-table-via-SAS/m-p/743495#M232800</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2021-05-25T07:08:06Z</dc:date>
    </item>
    <item>
      <title>Re: Create a temp table in SQL Server from SAS work table via SAS explicit pass through</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-temp-table-in-SQL-Server-from-SAS-work-table-via-SAS/m-p/743497#M232802</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/292396"&gt;@David_Billa&lt;/a&gt; - Here is the &lt;A href="https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-to-populate-temp-table-with-SAS-dataset/td-p/171226" target="_blank" rel="noopener"&gt;link&lt;/A&gt; I tried to provide before.&lt;/P&gt;</description>
      <pubDate>Tue, 25 May 2021 07:18:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-temp-table-in-SQL-Server-from-SAS-work-table-via-SAS/m-p/743497#M232802</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2021-05-25T07:18:56Z</dc:date>
    </item>
  </channel>
</rss>

