Click here to Skip to main content
15,892,161 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
create table mst_reg
(id int not null identity(1,1),
Name varchar(80),
Lastname varchar(80),
Fathername varchar(80),
Qualifiaction varchar(80),
Emailid varchar(80),
Phno int
)


insert into mst_reg values('aqib','javid','nijamudeen','BTechIT','aqib55@live.com',965557017796)


while executing the query to insert the data ito the table it shows
"
Msg 8115, Level 16, State 2, Line 1
Arithmetic overflow error converting expression to data type int.
The statement has been terminated." please help me
Posted
Comments
Xaavier 29-Aug-15 5:44am    
how can i store date of birth in sql server
and what is query for creating the date of birth

When you do an INSERT query, it's a very good idea to always list the columns you are going to insert the data into, or SQL will just start with the current first column and insert your values starting with that.
In your case, that first column is an IDENTITY column - so even if you did supply an integer value, it still would throw an exception.
Try:
SQL
INSERT INTO mst_reg (Name, Lastname, Fathername, Qualifiaction, Emailid, Phno) VALUES ('aqib', 'javid', 'nijamudeen', 'BTechIT', 'aqib55@live.com', 965557017796)
But please, if you are doing this via a high level language, remember to use parameterized queries! Do not concatenate strings to build a SQL command. It leaves you wide open to accidental or deliberate SQL Injection attack which can destroy your entire database. Use Parametrized queries instead
 
Share this answer
 
Comments
Xaavier 29-Aug-15 5:44am    
how can i store date of birth in sql server
and what is query for creating the date of birth
OriginalGriff 29-Aug-15 5:50am    
Set up a DATE or DATETIME column in your database and INSERT the value in ISO format (yyyy-MM-dd) - from a high level language pass the value as a DateTime via a query parameter
You are also storing the phno field as an integer, there is a limit on the size of number stored in numeric fields, store it as text.
 
Share this answer
 
Comments
Xaavier 29-Aug-15 5:44am    
how can i store date of birth in sql server
and what is query for creating the date of birth
Hi,
You can have your Phone no up to 10 digit, As Error itself suggest that Arithmetic overflow.
It means int have some limit. you can change that datatype to bigint

create table mst_reg
(

id bigint not null identity(1,1),
Name varchar(80),
Lastname varchar(80),
Fathername varchar(80),
Qualifiaction varchar(80),
Emailid varchar(80),
DOB DATETIME NOT NULL,
Phno bigint

)
 
Share this answer
 
v4
Comments
Xaavier 29-Aug-15 5:44am    
how can i store date of birth in sql server
and what is query for creating the date of birth
Ravindranath_Kanojiya 30-Aug-15 11:38am    
You can have a Column in you table and Datatype as DateTime
ALTER TABLE YourTableName ADD DOB DATETIME NOT NULL

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