TechNet
Export (0) Print
Expand All

TYPEPROPERTY (Transact-SQL)

 

THIS TOPIC APPLIES TO: yesSQL Server (starting with 2008)yesAzure SQL DatabaseyesAzure SQL Data Warehouse yesParallel Data Warehouse

Returns information about a data type.

Topic link icon Transact-SQL Syntax Conventions

-- Syntax for SQL Server, Azure SQL Database, Azure SQL Data Warehouse, Parallel Data Warehouse  
  
TYPEPROPERTY (type , property)  

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.

PropertyDescriptionValue returned
AllowsNullData type allows for null values.1 = True

0 = False

NULL = Data type not found.
OwnerIdOwner of the type.

Note: The schema owner is not necessarily the type owner.
Nonnull = The database user ID of the type owner.

NULL = Unsupported type, or type ID is not valid.
PrecisionPrecision for the data type.The number of digits or characters.

-1 = xml or large value data type

NULL = Data type not found.
ScaleScale for the data type.The number of decimal places for the data type.

NULL = Data type is not numeric or not found.
UsesAnsiTrimANSI 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.

int

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');  

C: 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');  

TYPE_ID (Transact-SQL)
TYPE_NAME (Transact-SQL)
COLUMNPROPERTY (Transact-SQL)
Metadata Functions (Transact-SQL)
OBJECTPROPERTY (Transact-SQL)
ALTER AUTHORIZATION (Transact-SQL)
sys.types (Transact-SQL)

Community Additions

ADD
Show:
© 2016 Microsoft