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

Databases

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Is there a way to see if a certain table in a database exists?

Thanks!

~Allison
 
on error resume next 'turn errors off

rs.open "SELECT top 1 FROM tableInQuestion"

if err.number <> 0 then 'see if there was an error
'apparently, the table doesn't exist
else
'apparently, the table does exist
end if

err.clear 'clear any error messages
on error goto 0 'turn errors back on

There may be a more elegant way to do it, but this would work.

:)
Paul Prewett

 
Paul's solution is quite simple and easy and should do just what you're asking, but if you're using SQL Server and want to know more about the tables in your database, check out the sys... tables - sysColumns, sysObjects. I can't recall the exact names of the tables, but with they start with &quot;sys&quot; and with a little familiarization of them, you can get info on your db's schema.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top