Today, we will introduce the SYS. all_ SQL _modules view in SQL Server, which stores definition statements such as functions, tables, stored procedures, and views.
SYS. all_objects view, which contains the names of all objects (function name, table name, stored procedure name, view name, (main/foreign) key name, and index name ).
In this view (SYS. all_objects), we are concerned with the following columns:
· Name: name of the stored function, table name, stored procedure name, view name, (Primary/foreign) key name, and index name
· Unique identifier of the object_id object, which is the connection condition between the object and SYS. all_ SQL _modules
· Type object type
Abbreviation description
FN SQL _scalar_function
If SQL _inline_table_valued_function
F foreign_key_constraint
U user_table
Sq service_queue
D default_constraint
S system_table
P SQL _stored_procedure
PK primary_key_constraint
V View
It internal_table
X extended_stored_procedure
Tr SQL _trigger
PC clr_stored_procedure
TF SQL _table_valued_function
Return to SYS. all_ SQL _modules. How can I write a function definition:
Select definition fromsys. all_ SQL _modules Sm
Inner join SYS. all_objects AO onsm. object_id = ao. object_id
Where name ='Functionname'And type ='FN'
If you want to describe the Definition Statement of the table, you do not need to write the Definition Statement of the view.
The preceding statements have been tested in SQL 2005 and 2008.