Always Create User Defined Data Types in the Database

While designing the database for your application, you should always create user defined data types for columns across the database. User-defined data types ensure consistency of column definitions across the database. User-defined datatypes are defined in terms of system datatypes. User-defined datatypes permit frequently used type information to be accessed by a name you choose with a specified rule, default, and display format attached to it. You can create a User-defined datatype using the sp_addtype system stored procedure. You need to create a User-defined datatype before it can be used in a table definition.

Here is an example that creates a user-defined datatype which is based on intrinsic datatype datetime named DateOfBirth that allows null values.

sp_addtype DateOfBirth, datetime, ‘NULL’

Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

Recent Articles: