TYPEPROPERTY
Returns information about a data type.
Syntax
TYPEPROPERTY (type, 'property')
Arguments
type
Is the name of the data type.
'property'
Is the type of information to be returned for the data type. property can be one of the following values:
Property | Description | Value returned |
---|---|---|
AllowsNull | Data type allows for null values. | 1 = True |
0 = False | ||
NULL = Data type not found. | ||
OwnerId | Owner of the type. | Nonnull = The database user ID of the type owner. |
Default is: 4 | ||
Note: The schema owner is not necessarily the type owner. | NULL = Unsupported type, or type ID is not valid. | |
Precision | Precision for the data type. | The number of digits or characters. |
-1 = xml or large value data type | ||
NULL = Data type not found. | ||
Scale | Scale for the data type. | The number of decimal places for the data type. |
NULL = Data type is not numeric or not found. | ||
UsesAnsiTrim | ANSI padding setting was ON when the data type was created. | 1 = True |
0 = False | ||
NULL = Data type not found, or it is not a binary or string data type. |
Return types
int
Example
SELECT TYPEPROPERTY(SCHEMA_NAME(schema_id) + '.' + name, 'OwnerId') AS owner_id , name , system_type_id , user_type_id, schema_id FROM sys.types ;