Comments - Openquery from SQL Server to MariaDB 10.1.48 using MariaDB ODBC Connector 3.1

2 months, 2 weeks ago John Smith

Figured it out. Someone else raised this on Stack Overflow for mySQL back in 2015. https://stackoverflow.com/questions/28440535/unable-to-filter-by-calculated-datetime-when-pulling-data-from-mysql-into-ms-sql

You have to convert the SQL server date to VARCHAR.

Code example using the StackOverflow solution, adapted to my situation:

DECLARE @TSQL varchar(8000) DECLARE @VAR varchar(29) SET @VAR = CONVERT(VARCHAR, cast(DATEADD(day, -5, getdate()) as date) ,120) --Select @var SET @TSQL = 'select modified from OPENQUERY(MariaDB, ''Select date_modified FROM tbl WHERE date(date_modified) >= ''''' + @VAR + ''''''') ' EXEC (@TSQL)

 
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.