Search code examples
sql-server-2005sql-server-2008sql-server-expresssqldatatypes

which datatype to use to store a mobile number


Which datatype shall I use to store mobile numbers of 10 digits (Ex.:9932234242). Shall I go for varchar(10) or for the big one- the "bigint".

If the number is of type- '0021-23141231' , then which datatype to use?


Solution

    • varchar/char long enough for all expected (eg UK numbers are 11 long)
    • check constraint to allow only digits (expression = NOT LIKE '%[^0-9]%')
    • format in the client per locale (UK = 07123 456 789 , Switzerland = 071 234 56 78)