SQL server 2012 TSQL : Msg 402, Level 16, State 1, Line 5 The data types datetime and time are incompatible in the add operator + Solution
Recently when we are migrating sql server 2008 code into Sql server 2012 we found this error .
Msg 402, Level 16, State 1, Line 5
The data types datetime and time are incompatible in the add operator.
we came to know that we cannot add (+) or subtract (-) datatime and time datatype columns as we do in SQL server 2008 .
To perform the same functionality we need to cast the time column to datetime column and then perform your action.
Delete LKD
from OPS_Schema.Alerting_LatestKPIData LKD
inner join OPS_Schema.Alerting_SecheduleConfiguration sc
on LKD.KPIName = SC.KPIName
WHERE SC.LatestCubeDate > =(LKD.latestDate + cast (LKD.LatestTime as datetime))
and sc.KPIName not like 'NO_DATA_%'
Msg 402, Level 16, State 1, Line 5
The data types datetime and time are incompatible in the add operator.
we came to know that we cannot add (+) or subtract (-) datatime and time datatype columns as we do in SQL server 2008 .
To perform the same functionality we need to cast the time column to datetime column and then perform your action.
Delete LKD
from OPS_Schema.Alerting_LatestKPIData LKD
inner join OPS_Schema.Alerting_SecheduleConfiguration sc
on LKD.KPIName = SC.KPIName
WHERE SC.LatestCubeDate > =(LKD.latestDate + cast (LKD.LatestTime as datetime))
and sc.KPIName not like 'NO_DATA_%'
Comments
Post a Comment