Header Ads

User Defined Data Types In SQL Server

User defined data types is useful to maintain the data type consistency in the database design. For example Phone Number is a field in several tables. These tables are may be created by several people in the team. All are may be use nvarchar as data type for Phone Number but length may be vary..to overcome these kind of issues we can use this feature.

Example:

Create Type [dbo].[PhoneNumber] from [nvarchar](12) NULL

Create table Employees (

Email nvarchar(50),
Phone PhoneNumber

)

In the above example PhoneNumber is a user defined data type.

3 comments:

Powered by Blogger.