User-Defined Datatypes

User-defined datatypes (UDDTs) allow you to define custom datatypes based on the system datatypes. For example, you could create a name datatype defined as varchar(30). Any columns you create with the name datatype would automatically be varchar(30). This helps create consistent fields across the database, which is especially helpful for join columns to ensure the absence of datatype mismatches. To create more complex UDDTs, you can bind rules and defaults (see Chapter 14, “Implementing Data Integrity”) to them to add even more functionality.

To create and drop UDDTs, use sp_addtype and sp_droptype:

Sp_addtype phone, 'char(13)' 
Sp_droptype phone

You can also add UDDTs through Enterprise Manager. Figure 12.1 shows the ...

Get Microsoft® SQL Server™ 2000 Unleashed, Second Edition 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.