Question

According to this docs on Interval Literals, this should be a valid INTERVAL,

SELECT {INTERVAL '326' YEAR(4)};

But when I try that on dbfiddle, I get,

Msg 155 Level 15 State 1 Line 1
'INTERVAL' is not a recognized ODBC date/time extension option.

Is that error a fault of dbfiddle, SQL Server, or the ODBC transport layer not knowing how to textify a interval -- I tried adding it to a date, hoping that would produce a date but alas same error?

If I try it without the {}, I get

Msg 102 Level 15 State 1 Line 1
Incorrect syntax near 'YEAR'.

Interval Literals

Was it helpful?

Solution

Looks like a dbfiddle isn't using ODBC. The "'INTERVAL' is not a recognized" error will be returned by SqlClient.

SqlClient looks like it supports ODBC escape sequences that have corresponding SQL Server data types but I can't find this behavior documented. The error occurs because there is currently no INTERVAL type in Microsoft SQL Server.

Licensed under: CC-BY-SA with attribution
Not affiliated with dba.stackexchange
scroll top