Problem in inserting values to a table in SQL

July 27, 2009 at 05:51:19
Specs: Win XP, Dual core/ 2GB
I have created a table in SQL Server as-

create table weatherreport
(places varchar(20),
cdate datetime,
maxm int,
minm int,
vdescription varchar(40))

Then I tried to insert the corresponding values as-

insert weatherreport
values('guwahati','07-01-09',31.4,26.7,'cloudy sky with one or two spells of rain or thunderstorms')

But I got a message as-
"String or binary data would be truncated.
The statement has been terminated."

Then I tried the following-

insert weatherreport(places,cdate,maxm, minm,vdescription)
values('guwahati','07-01-09',31.4,26.7,'cloudy sky with one or two spells of rain or thunderstorms')

But I got the same message. I couldn't find out my mistake. Please help me on this.


See More: Problem in inserting values to a table in SQL

Report •


#1
July 27, 2009 at 20:28:08
You should post this in the Programming forum.

http://ewen.uuuq.com/


Report •

#2
July 28, 2009 at 06:05:10
You're inserting decimal values in a column which you've said is an integer.

maxm and minm are both created as integers, then you're trying to drop in 31.4 and 26.7

In mysql, you'd create the table with decimal(x,y) (I *think* it's NUMERIC(x,y) in MS SQL) where x is the number of characters in the full number (including decimal places), and y is the number of characters that should come after the decimal point.


Report •

Related Solutions


Ask Question