I need to change the data type for a column from Datetime2(7)
to Datetime
where I have a lot of records with that format, so when I try to change the Data type I get the following error:
The conversion of a datetime2 data type to a datetime data type resulted in an out-of-range value.
How can I change the data and then change the data type for that column? The reason I need to switch to a less precise data type to for a application where it is not compatible with. This application connects directly so no conversion can be done in code. I am working inside SSMS.
Fixed one column with:
select *, cast(calldate as datetime)) * from records
But not for the other column using same Cast
- it gives the out-of range error. Maybe some fields are null - would that be a problem? If so I tried this(same error):
select *, cast(closedate as datetime) from records where closedate is not null