How to obtain the names of all tables in the database
Each database managed by SQL Server has a view named sysobjects, Which is system-level,
Therefore, its fully qualified name is -- sys. sysobjects. This table stores not only the tables in the database, but also
All the "objects" in a database, including the table's primary keys, stored procedures, triggers, and so on, are a total of 24 types-tables
(Table, specifically "user-defined Table") is only one of the 24 types of objects:
Run the following query statement to obtain all the data contained in the sys. sysobjects view.
SELECT * FROM sys. sysobjects
After the data is obtained, note that the column named "type" indicates the object type, that is, the 24 types mentioned above.
Type
AF = Aggregate function (CLR)
C = CHECK constraint
D = DEFAULT (constraint or stand-alone)
F = foreign key constraint
FN = SQL scalar function
FS = Assembly (CLR) scalar function
FT = Assembly (CLR) table-valued function
IF = SQL inline table-valued function
IT = Internal table
P = SQL stored procedure
PC = Assembly (CLR) stored procedure
PK = primary key constraint
R = Rule (old-style, stand-alone)
RF = Replication-filter-procedure
S = System base table
SN = Synonym
SQ = Service queue
TA = Assembly (CLR) DML trigger
TF = SQL table-valued-function
TR = SQL DML trigger
U = Table (user-defined)
UQ = UNIQUE constraint
V = View
X = Extended stored procedure
The table to be named (User-Defined table) is an object of the "U" type, and sys. objects is of the "S" type ". So,
The SQL statement should be --
SELECT name FROM sys. sysobjects WHERE type = 'U'
GO