I was trying to insert a date type columns but I'm getting an error mentioned in title
insert into table (Date)
select date from dbo.source
The date in dbo.source is of date data type and Date in Table is of smalldatetime data type, so when I try to insert i'm getting error as mentioned in title. I try to use convert(smalldatetime,date)
, but still I'm facing an issue. Anyone can help on this?
4条答案
按热度按时间l7mqbcuq1#
You probably have dates in your table out of this range 1900-01-01 through 2079-06-06, which is for smalldatetime. Date has a range of 0001-01-01 through 9999-12-31. You have to cap the dates to fit into smalldatetime.
swvgeqrz2#
I think in your
dbo.source
table there are records which is out of range ofsmalldatetime
range. Try this to find such out-of-range records -SmallDateTime range -
1900-01-01 through 2079-06-06
Date range -
0001-01-01 through 9999-12-31
y1aodyip3#
Either insert NULL for the values that don't fit:
Or don't insert these rows at all:
fcy6dtqo4#
Please, try with below query with range of date time datatype: