Testing for the existence of a table

G

Greg Shannan

All:

Is there some standard way I can test for the existence of a database table?

I am using ODBC with an ingres database; and I don't really want to open a query
like "select * ...." because I may end up reading the whole thing in, when all I
want to know is if the table exists.

I'm just wondering if there is a standard way in ado with ODBC.

TIA

.... Greg Shannan
 
B

Bernie Yaeger

Hi Greg,

The answer lies in Ingres. In SQL Server, for example, it's an easy matter
of identifying table objects by tablename using an sp with code like this:

if exists (select * from information_schema.tables where table_name =
'a_radj')

Is there similar objects in Ingres?

Bernie
 
G

Greg Shannan

Bernie:

Yes, there is a table with similar info. I was hoping not to have to use it,
but it seems this is the accepted way.

Thanks.

.... Greg Shannan
 
W

William \(Bill\) Vaughn

In SQL Server, we can do a SELECT [Name] FROM sysobjects WHERE [Name] =
@NameWanted
I expect that there might be similar tables in Ingress...

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
 
M

Miha Markic [MVP C#]

Just a note that only ado.net supported way to extract metadata without
doing selects is by using OleDbConnection.GetOleDbSchemaTable method.
 
M

Mark Davison via DotNetMonster.com

I have not tried this but you might be able to use:

select * from table where 1=0

I think this will bring in the table schema, if it exists, but no data. Be sure to wrap it in a try-catch to get the exception if there is no table. If this works, it will work regardless of the data source.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top