szymon_dybczak
Esteemed Contributor III

Hi @Alessio_F ,

This happens because in Databricks SQL both year and month functions are just aliases over following patterns:

- extract (YEAR FROM expr)

- extract(MONTH FROM expr)

szymon_dybczak_1-1779360372927.png

 

szymon_dybczak_0-1779360293676.png

When Databricks pushes a predicate or expression down to the remote SQL Server via JDBC, it translates these functions back to their canonical EXTRACT(...) form - which is not a recognized in SQL Server's T-SQL dialect.

You can try to rewrite your query or you can try to use remote_query() function which lets you run SQL queries directly against external database using native SQL syntax of th remote system.

Query external databases using the remote_query function | Databricks on Google Cloud

 

If my answer was helpful, please conisder marking it as accepted solution.