|
 |
asp_web_howto thread: Checking whether a table exists in a database
Message #1 by "Ihsan Habib" <ihsan@b...> on Wed, 25 Apr 2001 15:41:46
|
|
Hi,
Does anyone know what is the SQL command to check whether a table exists
or how can I check whether a particular table exists inside an Access
database?
Appreciate your help.
Ihsan.
Message #2 by Gregory_Griffiths@c... on Wed, 25 Apr 2001 16:24:38 +0100
|
|
Just do a standard query e.g. SELECT * FROM myTable and if that returns
an error - there should be info previously in this group about that -
then you know, else you could try doing a list of tables or a describe
on the table.
> -----Original Message-----
> From: ihsan@b... [mailto:ihsan@b...]
> Sent: 25 April 2001 15:42
> To: ihsan@b...; asp_web_howto@p...
> Subject: [asp_web_howto] Checking whether a table exists in a database
>
>
> Hi,
>
> Does anyone know what is the SQL command to check whether a
> table exists
> or how can I check whether a particular table exists inside an Access
> database?
>
> Appreciate your help.
>
> Ihsan.
>
Message #3 by "H. Carter Harris" <carter@t...> on Wed, 25 Apr 2001 10:46:04 -0500
|
|
An elegant way in SQL Server would be to do a query on the sysobjects table
for the table name. If it exists the table is there.
-----Original Message-----
From: Gregory_Griffiths@c...
[mailto:Gregory_Griffiths@c...]
Sent: Wednesday, April 25, 2001 10:25 AM
To: ASP Web HowTo
Subject: [asp_web_howto] RE: Checking whether a table exists in a
database
Just do a standard query e.g. SELECT * FROM myTable and if that returns
an error - there should be info previously in this group about that -
then you know, else you could try doing a list of tables or a describe
on the table.
> -----Original Message-----
> From: ihsan@b... [mailto:ihsan@b...]
> Sent: 25 April 2001 15:42
> To: ihsan@b...; asp_web_howto@p...
> Subject: [asp_web_howto] Checking whether a table exists in a database
>
>
> Hi,
>
> Does anyone know what is the SQL command to check whether a
> table exists
> or how can I check whether a particular table exists inside an Access
> database?
>
> Appreciate your help.
>
> Ihsan.
>
Message #4 by "Ken Schaefer" <ken@a...> on Thu, 26 Apr 2001 11:10:09 +1000
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
: Does anyone know what is the SQL command to check whether a table exists
: or how can I check whether a particular table exists inside an Access
: database?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Query msysobjects table.
SELECT Name
FROM MSysObjects
WHERE Type = 1
AND Name = 'NameOfTable'
If objRS is EOF then the table does not exist. Otherwise, it does
Cheers
Ken
Message #5 by "Ihsan Habib" <ihsan@b...> on Thu, 26 Apr 2001 02:44:39
|
|
Does the following work for an Access Database?
Thanks,
Ihsan.
Query msysobjects table.
SELECT Name
FROM MSysObjects
WHERE Type = 1
AND Name = 'NameOfTable'
If objRS is EOF then the table does not exist. Otherwise, it does
Cheers
Ken
Message #6 by "Ken Schaefer" <ken@a...> on Thu, 26 Apr 2001 18:15:55 +1000
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
: Does the following work for an Access Database?
:
: Thanks,
:
: Ihsan.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Yes. Note: I don't think this is the way the MS recommends you do it, and so
it might break in future versions of Access. Your other alternatives are to
use ADOX or the ADO Schema
Cheers
Ken
: Query msysobjects table.
:
: SELECT Name
: FROM MSysObjects
: WHERE Type = 1
: AND Name = 'NameOfTable'
:
: If objRS is EOF then the table does not exist. Otherwise, it does
|
|
 |