2.5. USER-DEFINED DATA TYPES

User-defined data types are data types based on intrinsic system types given a name by the user, which may then be used in future DDL statements within the database where they were created.

It is particularly useful to create a user-defined data type for a unique key that has foreign key columns (usually in another table) that refer to it. Creating a user-defined type and using it for the unique key and foreign key column definitions ensures that they are the same data type.

The following parts of user-defined data types must be provided when created.

  • Name.

  • Underlying System Data Type— see Table 2-50.

  • Nullability— 'NULL', 'NOT NULL', 'NONULL' in single quotes, see below. For a discussion of default nullability see ...

Get Transact-SQL Desk Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.