Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

table exists

Status
Not open for further replies.

Silvano

Programmer
Jul 16, 2001
386
US
is there a way to get a list of all tables that exist in a specific database without querieng the table itself? Sylvano
dsylvano@hotmail.com
 
There may be an easier way, depending on your database server. Check the ocumentation for your database server to see if there's a table in each database that describes the structure of the database. In SQL Server, it's a table called sysobjects, and it holds records describing all the tables, constraints, views, etc. You could query it like this:
Code:
   <cfquery name=&quot;qryDBTables&quot; datasource=&quot;myDSN&quot; dbtype=&quot;ODBC&quot;>
      SELECT name
      FROM sysobjects
      WHERE xtype='U'
   </cfquery>
In this case, I selected xtype='U' because I wanted user tables. Other values for xtype seem to be S for system table, P for stored procedures, V for views, PK for primary key constraints, and F for foreign key constraints.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top