Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
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.

I am not a SQL server guy, but the problem is most likely the datetime. Most datetimes are formatted like:
2009-07-21
If you still have a problem, try adding a time:
2009-07-21 13:42
If you still have a problem, read the manual on SQL Server datetime.

Have a look at the dates thing, as above.
Also, 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.

![]() |
![]() |
![]() |
| Login or Register to Reply | |
| Login | Register |
| Ads by Google |