<?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: get all tables in  a SQL database using PROC SQL in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/get-all-tables-in-a-SQL-database-using-PROC-SQL/m-p/396084#M95585</link>
    <description>&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;PROC&lt;/FONT&gt;&lt;/STRONG&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;SQL&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;SELECT&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; *&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;FROM&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; DICTIONARY.TABLES&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;WHERE&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; UPCASE(LIBNAME) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;like&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="3"&gt;'the library name u are searching for'&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;AND&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; UPCASE(MEMNAME) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;like&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="3"&gt;'if u remember one of the&amp;nbsp;table name'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; ;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;QUIT&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;for example; the libname is ECOWAS and one of the table name is Nigeria&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;PROC&lt;/FONT&gt;&lt;/STRONG&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;SQL&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;SELECT&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; *&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;FROM&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; DICTIONARY.TABLES&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;WHERE&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; UPCASE(LIBNAME) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;like&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="3"&gt;'ECOWAS'&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;AND&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; UPCASE(MEMNAME) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;like&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="3"&gt;'NIG%'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; ;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;QUIT&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 14 Sep 2017 20:13:58 GMT</pubDate>
    <dc:creator>niyiawe</dc:creator>
    <dc:date>2017-09-14T20:13:58Z</dc:date>
    <item>
      <title>get all tables in  a SQL database using PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/get-all-tables-in-a-SQL-database-using-PROC-SQL/m-p/69018#M14991</link>
      <description>Hello all-&lt;BR /&gt;
I am seeking to get all the table names from a SQL database. I am been searching on the web but have not found an adequate answer-&lt;BR /&gt;
&lt;BR /&gt;
So far I have:&lt;BR /&gt;
&lt;BR /&gt;
libname X oledb provider=sqloledb dsn='SQLXXXDR' properties=("Integrated Security"=SSPI "Persist Security Info"=True&lt;BR /&gt;
"Initial Catalog"=medX) ;&lt;BR /&gt;
&lt;BR /&gt;
This connects fine, but the problem I have is this-&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
PROC SQL;&lt;BR /&gt;
SELECT *&lt;BR /&gt;
FROM DICTIONARY.TABLES&lt;BR /&gt;
WHERE UPCASE(LIBNAME)='X';&lt;BR /&gt;
QUIT;&lt;BR /&gt;
&lt;BR /&gt;
It tellsm e no rows are connected. Any help would be much appreciated. &lt;BR /&gt;
Thanks, &lt;BR /&gt;
&lt;BR /&gt;
Lawrence</description>
      <pubDate>Tue, 24 May 2011 16:42:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/get-all-tables-in-a-SQL-database-using-PROC-SQL/m-p/69018#M14991</guid>
      <dc:creator>_LB</dc:creator>
      <dc:date>2011-05-24T16:42:34Z</dc:date>
    </item>
    <item>
      <title>Re: get all tables in  a SQL database using PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/get-all-tables-in-a-SQL-database-using-PROC-SQL/m-p/69019#M14992</link>
      <description>you might need &lt;BR /&gt;
SCHEMA=&lt;BR /&gt;
to reveal names of tables</description>
      <pubDate>Tue, 24 May 2011 18:40:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/get-all-tables-in-a-SQL-database-using-PROC-SQL/m-p/69019#M14992</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2011-05-24T18:40:28Z</dc:date>
    </item>
    <item>
      <title>Re: get all tables in  a SQL database using PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/get-all-tables-in-a-SQL-database-using-PROC-SQL/m-p/69020#M14993</link>
      <description>Just as Peter said. Do you check the X library by double-click .Did you see the table list in this X library?&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
      <pubDate>Mon, 30 May 2011 09:22:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/get-all-tables-in-a-SQL-database-using-PROC-SQL/m-p/69020#M14993</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-05-30T09:22:11Z</dc:date>
    </item>
    <item>
      <title>Re: get all tables in  a SQL database using PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/get-all-tables-in-a-SQL-database-using-PROC-SQL/m-p/69021#M14994</link>
      <description>The lazy way...&lt;BR /&gt;
&lt;BR /&gt;
libname sqldb "aldsjlkdfjlksjflkjfdlkasjf";&lt;BR /&gt;
&lt;BR /&gt;
proc contents data=sqldb._all_ out=tablesAndColumns; run;&lt;BR /&gt;
&lt;BR /&gt;
This will produce a dataset (tablesAndColumns) that looks like any SAS proc contents.</description>
      <pubDate>Wed, 01 Jun 2011 17:21:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/get-all-tables-in-a-SQL-database-using-PROC-SQL/m-p/69021#M14994</guid>
      <dc:creator>jj030655</dc:creator>
      <dc:date>2011-06-01T17:21:28Z</dc:date>
    </item>
    <item>
      <title>Re: get all tables in  a SQL database using PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/get-all-tables-in-a-SQL-database-using-PROC-SQL/m-p/396084#M95585</link>
      <description>&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;PROC&lt;/FONT&gt;&lt;/STRONG&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;SQL&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;SELECT&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; *&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;FROM&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; DICTIONARY.TABLES&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;WHERE&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; UPCASE(LIBNAME) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;like&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="3"&gt;'the library name u are searching for'&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;AND&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; UPCASE(MEMNAME) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;like&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="3"&gt;'if u remember one of the&amp;nbsp;table name'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; ;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;QUIT&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;for example; the libname is ECOWAS and one of the table name is Nigeria&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;PROC&lt;/FONT&gt;&lt;/STRONG&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;SQL&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;SELECT&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; *&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;FROM&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; DICTIONARY.TABLES&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;WHERE&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; UPCASE(LIBNAME) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;like&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="3"&gt;'ECOWAS'&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;AND&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; UPCASE(MEMNAME) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;like&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="3"&gt;'NIG%'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; ;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;QUIT&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Sep 2017 20:13:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/get-all-tables-in-a-SQL-database-using-PROC-SQL/m-p/396084#M95585</guid>
      <dc:creator>niyiawe</dc:creator>
      <dc:date>2017-09-14T20:13:58Z</dc:date>
    </item>
    <item>
      <title>Re: get all tables in  a SQL database using PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/get-all-tables-in-a-SQL-database-using-PROC-SQL/m-p/396089#M95587</link>
      <description>&lt;P&gt;I've read (but not verified/tested) that SQL Server supports the&amp;nbsp;&lt;STRONG&gt;information_schema&lt;/STRONG&gt; view that allows you to find all of the tables and attributes. &amp;nbsp;If that's the case, you could use PROC SQL passthrough to CONNECT to the database and issue a query that brings that information back into SAS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See this blog post for more info: &lt;A href="http://blogs.sas.com/content/sasdummy/2012/05/18/using-proc-sql-to-get-the-schema-of-a-mysql-database/" target="_self"&gt;Using PROC SQL to get the schema of a MySQL database&lt;/A&gt;. &amp;nbsp;It's written for MySQL, but should be easy to adapt.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Sep 2017 20:22:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/get-all-tables-in-a-SQL-database-using-PROC-SQL/m-p/396089#M95587</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2017-09-14T20:22:25Z</dc:date>
    </item>
    <item>
      <title>Re: get all tables in  a SQL database using PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/get-all-tables-in-a-SQL-database-using-PROC-SQL/m-p/519363#M140660</link>
      <description>&lt;P&gt;In similar fashion, could you please help me with the document to get attributes of DB2 tables from one schema in SAS? I tried the following code, but it is not working.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;24         proc sql noprint;
25         	connect to db2 (datasrc=db2gtu
26         		authdomain=DB2AuthODS
27         		connection=global);
28         	create table work.status as
29         		(select * from
30               information_schema.tables
ERROR: Librefs are restricted to eight characters. information_schema has been truncated.
31             where table_schema="CREFIUS");
NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.
32         	disconnect from db2;
NOTE: Statement not executed due to NOEXEC option.
33         quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 07 Dec 2018 05:13:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/get-all-tables-in-a-SQL-database-using-PROC-SQL/m-p/519363#M140660</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2018-12-07T05:13:39Z</dc:date>
    </item>
    <item>
      <title>Re: get all tables in  a SQL database using PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/get-all-tables-in-a-SQL-database-using-PROC-SQL/m-p/519381#M140665</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/8409"&gt;@Babloo&lt;/a&gt; - the post was about SQL Server and you are assuming the same technique will work in DB2? Working out how to do this in DB2 is as simple as googling "how to list tables in db2". That is how I found this useful link:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://chartio.com/resources/tutorials/how-to-list-tables-in-ibm-db2/" target="_blank"&gt;https://chartio.com/resources/tutorials/how-to-list-tables-in-ibm-db2/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now you can try the recommended way like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
connect to db2 (datasrc=db2gtu authdomain=DB2AuthODS
connection=global);
create table DB_Tables as
select * from connection to db2
(SELECT
  *
FROM
  SYSIBM.SYSTABLES
WHERE
  type = 'T';
);
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Dec 2018 08:29:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/get-all-tables-in-a-SQL-database-using-PROC-SQL/m-p/519381#M140665</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2018-12-07T08:29:58Z</dc:date>
    </item>
  </channel>
</rss>

