TSQL datetime versus datetime2 compatibility issue and the Native Client 11.0

229 Views Asked by At

The following code failed when we had to switch to the SQL Server Native Client 11.0 driver (so that we could upgrade our TLS to 1.2):

convert(varchar(15),getdate()+cast(1 as datetime),10)

The error was:

Microsoft SQL Server Native Client 11.0 : The data types datetime2 and datetime are incompatible in the add operator.

We can change the T-SQL code to get around this (maybe with a DATEADD), but it is legacy code in 250 scripts in our system. Is there something we can do at the native client interface level or is there a global option we can set?

0

There are 0 best solutions below