How do I get list of all tables in a database using TSQL?

前端 未结 17 1785
无人及你
无人及你 2020-11-22 14:37

What is the best way to get the names of all of the tables in a specific database on SQL Server?

17条回答
  •  有刺的猬
    2020-11-22 15:20

    SELECT sobjects.name
    FROM sysobjects sobjects
    WHERE sobjects.xtype = 'U'
    

    Here is a list of other object types you can search for as well:

    • AF: Aggregate function (CLR)
    • C: CHECK constraint
    • D: Default or DEFAULT constraint
    • F: FOREIGN KEY constraint
    • L: Log
    • FN: Scalar function
    • FS: Assembly (CLR) scalar-function
    • FT: Assembly (CLR) table-valued function
    • IF: In-lined table-function
    • IT: Internal table
    • P: Stored procedure
    • PC: Assembly (CLR) stored-procedure
    • PK: PRIMARY KEY constraint (type is K)
    • RF: Replication filter stored procedure
    • S: System table
    • SN: Synonym
    • SQ: Service queue
    • TA: Assembly (CLR) DML trigger
    • TF: Table function
    • TR: SQL DML Trigger
    • TT: Table type
    • U: User table
    • UQ: UNIQUE constraint (type is K)
    • V: View
    • X: Extended stored procedure

提交回复
热议问题