TYPEPROPERTY (Transact-SQL)
SQL Server 2012
Returns information about a data type.
Returns NULL on error or if a caller does not have permission to view the object.
In SQL Server, a user can only view the metadata of securables that the user owns or on which the user has been granted permission. This means that metadata-emitting, built-in functions such as TYPEPROPERTY may return NULL if the user does not have any permission on the object. For more information, see Metadata Visibility Configuration.
A. Identifying the owner of a data type
The following example returns the owner of a data type.
SELECT TYPEPROPERTY(SCHEMA_NAME(schema_id) + '.' + name, 'OwnerId') AS owner_id, name, system_type_id, user_type_id, schema_id FROM sys.types;
B. Returning the precision of the tinyint data type
The following example returns the precision or number of digits for the tinyint data type.
SELECT TYPEPROPERTY( 'tinyint', 'PRECISION');
