Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

I have to create a column in sql server database for Mobile number?

What data type i have to use to store mobile numbers?
Purely it should store only 10 digits no special chars and alphabets.
Posted
Updated 1-Dec-16 4:20am
Comments
gvprabu 11-Jun-13 5:46am    
yes, You can use VARCHAR(10) or CHAR(10) datatype for this, But Don't use like NUMERIC(10,0) or other datatypes
Rockstar_ 11-Jun-13 5:47am    
Why?
Rockstar_ 11-Jun-13 5:49am    
If i write varchar(10), then it accepts special chars and alphabets also?
gvprabu 11-Jun-13 5:50am    
yes correct, then u will check this in front end or back end while all values are numbers or not.
gvprabu 11-Jun-13 5:53am    
Hi,
SELECT ISNUMERIC('123A4567890'), ISNUMERIC('1234567890')
Check like this....

Telephone datatype is set to numeric
 
Share this answer
 
create table mobile (Mobile_Number varchar(15))
insert into mobile values(9934567890)
 
Share this answer
 
Comments
CHill60 2-Dec-16 11:46am    
No different to Solution 1 posted over 3 years ago and then you use the wrong type in the insert statement

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900