-- Query tables and views
Select * From information_schema.tables
-- Query view
Select * From information_schema.views
-- Query all tables in the database
Select * From sysobjects where xtype = 'U' and status> 0
Sp_tables
Or:
Select * From information_schema.tables
Or:
Select * From sysobjects where xtype = 'U' and status> 0
Sysobjects
Each object created in the database (constraints, default values, logs, rules, stored procedures, etc.) occupies one row in the table. Each temporary object occupies one row in the table only in tempdb.
Column name data type description
Name sysname object name.
Id int ID of the object.
Xtype char (2) object type. It can be one of the following object types:
C = check Constraints
D = default value or default Constraint
F = foreign key constraint
L = Log
Fn = scalar function
If = embedded table functions
P = Stored Procedure
PK = primary key constraint (type: K)
Rf = copy and filter the Stored Procedure
S = system table
TF = table functions
Tr = trigger
U = User table
Uq = unique constraint (type is K)
V = View
X = Extended Stored Procedure
User ID of the UID smallint owner object.
Info smallint is retained. For internal use only.
Status int is retained. For internal use only.
Base_schema _
Ver int is retained. For internal use only.
Replinfo int is retained. For replication.
The object ID of the parent object of parent_obj int (for example, this ID is the table ID for triggers or constraints ).
The creation date of the crdate datetime object.
Ftcatid smallint is the full-text directory identifier of all user tables registered with the full-text index. It is 0 for all user tables not registered.
Schema_ver int version number, which increases each time the schema of the table is changed.
Stats_schema _
Ver int is retained. For internal use only.
Type char (2) object type. It can be one of the following values:
C = check Constraints
D = default value or default Constraint
F = foreign key constraint
Fn = scalar function
If = embedded table functions
K = primary key or unique constraint
L = Log
P = Stored Procedure
R = rule
Rf = copy and filter the Stored Procedure
S = system table
TF = table functions
Tr = trigger
U = User table
V = View
X = Extended Stored Procedure
Userstat smallint is retained.
Sysstat smallint internal status information.
Indexdel smallint is retained.
Refdate datetime is reserved for future use.
Version int is reserved for later use.
Deltrig int is retained.
Instrig int is retained.
Updtrig int is retained.
Seltrig int is retained.
CATEGORY int is used for publishing, constraints, and identifiers.
Cache smallint is retained.