Another way to test for the existence of a table : INFORMATION_SCHEMA « System « SQL Server / T-SQL






Another way to test for the existence of a table

 


4>
5> create table Billings (
6>     BankerID           INTEGER,
7>     BillingNumber      INTEGER,
8>     BillingDate        datetime,
9>     BillingTotal       INTEGER,
10>     TermsID            INTEGER,
11>     BillingDueDate     datetime ,
12>     PaymentTotal       INTEGER,
13>     CreditTotal        INTEGER
14>
15> );
16> GO
1>
2>
3> IF EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES
4>         WHERE (TABLE_NAME = 'Billing' AND
5>         TABLE_TYPE = 'BASE TABLE'))
6>     DROP TABLE Billing
7> GO
1>
2> drop table Billings;
3> GO

 








Related examples in the same category

1.INFORMATION_SCHEMA.TABLES
2.Query INFORMATION_SCHEMA.VIEWS