OBJECT_ID参数

以下列出全部 Object 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

PG = Plan guide

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

TT = Table type

U = Table (user-defined)

UQ = UNIQUE constraint

V = View

X = Extended stored procedure

可以通过这个查询语句获取当前数据库中各个数据库表,视图,存储过程等数量。

SELECT CASE TYPE
WHEN ‘U’ THEN ‘User Defined Tables’
WHEN ‘V’ THEN ‘View’
WHEN ‘S’ THEN ‘System Tables’
WHEN ‘IT’ THEN ‘Internal Tables’
WHEN ‘P’ THEN ‘Stored Procedures’
WHEN ‘PC’ THEN ‘CLR Stored Procedures’
WHEN ‘X’ THEN ‘Extended Stored Procedures’
WHEN ‘FN’ THEN ‘Scalar-valued Functions’
WHEN ‘IF’ THEN ‘Table-valued Functions’
END AS Objects,
COUNT(*) AS Counts
FROM SYS.OBJECTS
WHERE TYPE IN (‘U’,’V’,’S’,’IT’,’P’,’PC’,’X’,’FN’,’IF’)
GROUP BY TYPE

你可能感兴趣的:(sql,sql-server)