Page 1 of 1

Comparing Time(7) in SQL server

Posted: Mon Feb 09, 2015 8:26 pm
by phanikumar
Hi,

I have a scenario where I need to compare time datatype from Datastage to Time(7) in SQL server in my update query.

Upon running below is the error message I get

The data types time and datetime2 are incompatible in the is operator

ODBC function is reading Time(7) as DateTime2 data type which is not able to compare against Time from DataStage.

any thoughts on how to achieve this?

Regards
Kumar

Posted: Mon Feb 09, 2015 11:41 pm
by chulett
What kind of 'comparison' are you attempting? I would imagine you could convert both the strings in a common format and then compare those.

Posted: Wed Feb 11, 2015 9:36 pm
by phanikumar
Time(7) in SQL Server is DateTime2.

When comparing Time from Datastage to DateTime2 in SQL server it's issuing a error message as mismatch in Datatypes.

We then agreed to change the datatype in the target SQL Server to DateTime which is equivalent to TimeStamp in DataStage.

We are now able to compare TimeStamp in DataStage as against to DateTime in Sql Server.

Finally managed to fix the issue by changing the datatypes.

Regards
Kumar