Sunday 22 April 2012

Create User Defined Data Type in SQL SERVER

Written By:- Isha Malhotra (Software Developer)

Email:-malhotra.isha3388@gmail.com.
Note: -if you find this article helpful then kindly leave your comment

For Asp.net Training with C# and Sql Server Click Here


Create User Defined Data Type in SQL SERVER
Sql server allows us to create data type according to our wish. Sometimes in organisation there is requirement when a company restrict the employee to use data type according to organisation. In that situation they create their own datatype.

Syntax
create   type   Type_name   from      Existing_type     null/not null;


Example

create type id from int not null;
create type Description from varchar(500) not null;
in this example we create the type id as int which is not null.
We can assign this data type into the table.
For example
create table Employee(Emp_id id primary key, Emp_name varchar(100), Emp_Detail Description );

Note: - we can also drop the user defined data type but first we have to remove this data type from all table where it is using.

1 comment: