fn_listextendedproperty (Transact-SQL)
Returns extended property values of database objects.
fn_listextendedproperty (
{ default | 'property_name' | NULL }
, { default | 'level0_object_type' | NULL }
, { default | 'level0_object_name' | NULL }
, { default | 'level1_object_type' | NULL }
, { default | 'level1_object_name' | NULL }
, { default | 'level2_object_type' | NULL }
, { default | 'level2_object_name' | NULL }
)
This is the format of the tables returned by fn_listextendedproperty.
Column name | Data type |
|---|---|
objtype | sysname |
objname | sysname |
name | sysname |
value | sql_variant |
If the table returned is empty, either the object does not have extended properties or the user does not have permissions to list the extended properties on the object. When returning extended properties on the database itself, the objtype and objname columns will be NULL.
If the value for property_name is NULL or default, fn_listextendedproperty returns all the properties for the specified object.
When the object type is specified and the value of the corresponding object name is NULL or default, fn_listextendedproperty returns all extended properties for all objects of the type specified.
The objects are distinguished according to levels, with level 0 as the highest and level 2 the lowest. If a lower-level object, level 1 or 2, type and name are specified, the parent object type and name should be given values that are not NULL or default. Otherwise, the function returns an empty result set.
Permissions to list extended properties of objects vary by object type. For a complete list of permissions, see Using Extended Properties on Database Objects.
A. Displaying extended properties on a database
The following example displays all extended properties set on the database object itself.
USE AdventureWorks; GO SELECT objtype, objname, name, value FROM fn_listextendedproperty(default, default, default, default, default, default, default); GO
Here is the result set.
objtype objname name value --------- --------- ----------- ---------------------------- NULL NULL MS_Description AdventureWorks Sample OLTP Database (1 row(s) affected)
B. Displaying extended properties on all columns in a table
The following example lists extended properties for columns in the ScrapReason table. This is contained in the schema Production.
USE AdventureWorks; GO SELECT objtype, objname, name, value FROM fn_listextendedproperty (NULL, 'schema', 'Production', 'table', 'ScrapReason', 'column', default); GO
Here is the result set.
objtype objname name value ------- ----------- ------------- ------------------------ COLUMN ScrapReasonID MS_Description Primary key for ScrapReason records. COLUMN Name MS_Description Failure description. COLUMN ModifiedDate MS_Description Date the record was last updated. (3 row(s) affected)
C. Displaying extended properties on all tables in a schema
The following example lists extended properties for all tables contained in the Sales schema.
USE AdventureWorks; GO SELECT objtype, objname, name, value FROM fn_listextendedproperty (NULL, 'schema', 'Sales', 'table', default, NULL, NULL); GO
