Monday, 20 July 2015

TSQL: Catalog Views

sys.objects - shows one row per object in the scoped database
sys.tables - shows one row per table in the scoped database
sys.columns - shows columns associated with tables, views, and other objects
sys.identity_columns - shows a list of all columns in all tables with identity property. inherits columns for sys.columns along with seed, incrementing value, last value
sys.computed_columns - shows all computed columns (0 - not stored, computed at runtime; 1 - stored in the DB)
sys.types - list of all data types

sys.triggers - list of all triggers
sys.sql_modules - shows the text definition of the trigger
sys.dm_sql_referencing_entities - list all references to a specific database object


Catalog views covering the various constraint types:
sys.key_constraints
sys.check_constraints
sys.default_constraints
sys.foreign_keys
sys.foreign_key_columns


Samples:

select * from sys.dm_sql_referencing_entities('Person', 'Object')
-- where 'Person' is the entity name, and 'Object' is the reference class

select object_name(parent_id) from sys.triggers

No comments:

Post a Comment