Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 The purpose of Name:nvarchar(25)?

Author  Topic 

sqlontherun101
Starting Member

16 Posts

Posted - 2009-11-13 : 13:49:32
Hi Friend,

When i looked at the tables in Adventure works.. the design of each columns seems a bit strange... since adventure work shows industrial standards i want ot follow it...

However i have few issues with it:

In Phone number columns they have given type for the column as
Phone:nvarchar(25)

1. Why they've add type as Phone:nvarchar(25)?
2. what's the difference bewteen Phone:nvarchar(25) and nvarchar(25)?
3. I've tried to mannualy type the type of phone column as
Phone:nvarchar(25) but it gave me an error. why it gives me an error?

how do i make the phone column of type Phone:nvarchar(25)?

thanks

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2009-11-13 : 14:50:19
the phone number columns are defined with a "user defined Type". The type is based on nvarchar(25). When you look at the column via Object Explorer the display is such that is shows the type name, the underlying datatype if it is a custom type as well as the nullability. That is a convenience to the user. ie:

Phone (Phone(nvarchar(25)), null)

However if you refer the type in code you should only use the type name (phone). So:

declare @p phone
set @p = N'123-1234'
select @p as [phoneNumber]



Be One with the Optimizer
TG
Go to Top of Page
   

- Advertisement -