determine if the database exists
If db_id (N ' DATABASENAME ') is not null
the methods for judging tables, views, stored procedures, and cursors are summarized as follows:
use databasename--jump to the specified database
go
if object_id (n ' a ', n ' U ') is not null
drop Table a
go
Note: A is a table and U represents a data table type
Type code similar to U, as shown below
Object type:
AF = aggregate function (CLR)
C = CHECK Constraint
D = DEFAULT (constrained or standalone)
F = FOREIGN KEY constraint
PK = PRIMARY KEY constraint
P = SQL Stored Procedure
PC = assembly (CLR) stored procedure
FN = SQL scalar function
FS = assembly (CLR) scalar functions
FT = assembly (CLR) table-valued function
R = Rule (Legacy, standalone)
RF = Replication filtering process
SN = synonym
TR = SQL DML Trigger
IF = SQL Inline Table-valued function
TF = SQL Table-valued function
U = table (user-defined type)
UQ = UNIQUE Constraint
V = view
X = Extended Stored Procedure
IT = Internal table
I've introduced sysobjects this system table before. Custom tables, stored procedures ..... will be stored in this form. So.....
Whether the columns in the table exist
if col_length ( ,  ' C ' is   not   null  
Note: A is a table name
c is the column name
Or:
Select * fromsyscolumnswhereid=object_id (' table name ') and name=' column name '
Note: A description record of this column is returned, and there is no return null;
T-SQL judgment exists (database, table, stored procedure, constraints ...) and columns)