When I looked at the tables in Adventure works, the design of each columns seems a bit strange. Since AdventureWorks shows industrial standards I want to follow it.
In Phone number columns they have given type for the column as Phone:nvarchar(25)
How do I make the phone column of type Phone:nvarchar(25)?
There's a user defined type in the Adventure Works database called Phone
. If you want to create it yourself, you can do:
create type dbo.Phone from nvarchar(25) null
Then you can do:
create table Contact (id int identity(1,1), name nvarchar(255), phone dbo.Phone)
You can see that a column of type Phone
is an nvarchar(25) null
column by default. You can use this for shorthand if you have lots of tables or you'd like to have one way to change all Phone
columns at once. It's a practice--not really a "best" practice unless it's in some special cases.