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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query to list table names? 2

Status
Not open for further replies.

estafford

Programmer
Sep 5, 2002
22
0
0
US
Is it possible to return a list of tables from an access 2000 database using a SQL statement?

Thanks
ES
 
That info is covered in this faq

faq181-690
 
Can you write me the correct address of the FAQ about listing all the tables of an Access db with a SQL query? The page you linked doesn't exist.
Thanks
Fabrizio
 
fabry,

It should work. MSysObjects is a (Hidden) system table which includes the object (including table) names. It is a 'documented' object, which impllies that it has been, is, and will continue to be in Ms. A for a while.

To get to the faq, just click on the link,

MichaelRed
m.red@att.net

There is never time to do it right but there is always time to do it over
 
can you show me how to check if a table exists on my Access db? I looked at the page you linked about ADOX Catalog Object, but I found it very difficult for me... I'm sorry.
Thanks
Fabry
 
the ADOX info is scattered and I had to sort through it to get what I needed. I was then able to write the script I needed from that. It's all in VB and I prefer javascript so there was a lot of translation.

This is a javascript example for you question.(server side)

function findTable(tblname){
var Catalog = Server.CreateObject("ADOX.Catalog")
var CatConn = Server.CreateObject("ADODB.connection")
CatConn.open(-your connection string.mdb-)
Catalog.activeConnection = CatConn
var tbl = Catalog.tables

for(i=0; i<tbl.count; i++){
if(tbl(i).Type == &quot;TABLE&quot; && tbl(i).Name == tblname){
tblexists = true;
break;
}
}

CatConn.close()
CatConn = null
Catalog = null
}
}

Ed
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top