You can create User Defined Data Types in SQL server
management Studio using given steps
You need to use Object Explorer to create User
Defined Data Types
Follow the Given Steps in Below Images
Step 1 :- In Object Explorer Expand Databases, and then select
any database (as your requirement)
Step 2 :- Expand Selected Database
Step 3 :- Expand Programmability and then Right Click on Types and Then select
user-Defined Data Types and open it
Step 4 :- In the New User-defined Data Type dialog box, in the Schema box, type the schema to own this data type, or use the browse button to select the schema. After browse button you need to follow 6 and 7 steps to choose Schema name.
Step 5 :-
In the Name box, type a name for the new data type. Take a look at step 8 at given image.
Step 6 :- In the Data type box, select the data type that the new data type will be based on. [ You can see step 9 in given image ]
Step 7 :- Complete the Length, Precision, and Scale boxes if
appropriate for that data type.
Step 8 :- Check Allow NULLs if the new data type can permit NULL
In the Binding area, complete the Default or Rule boxes if you want to bind a default or rule to the new data type. Defaults and rules cannot be created in SQL Server Management Studio. Use Transact-SQL. Example code for creating defaults and rules are available in Template Explorer.
After creating You can see that a user defined data
type is created [Example UniqueID]
How to use These UserDefined data type
You can use these user define data type while creating table
Or you can use SQL query as
CREATE TABLE [dbo].[EmployeeDetails](
[EmpID] [dbo].[UniqueID] NOT NULL,
[EmpName] [char](30) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
) ON [PRIMARY]
You can verify after creating table
If you want
to take a look about it dependencies Means user defined data type where using
so you can follow given steps in below images
And click on View Dependencies