Amedee said:
in Dutch it's in Data - Externe gegevens
ophalen - Nieuwe databasequery...
I don't know it in Dutch <g> but I think you are referring to MS Query.
In MS Query, SQL is not just SQL: it's either MS Query's SQL or it's
the DBMS's SQL.
Write the SQL on the DBMS Server e.g. QA in SQL Server. Copy and paste
the SQL text to the MS Query SQL window and it should work: MS Query
will not recognize the syntax as being its own so will send it
unaltered to the DBMS for execution. However there is a chance MS Query
will think it recognizes the syntax, try to interpret it and fail. The
best way round this is - ironically - to use some syntax proprietary to
the DBMS and not recognizable by MS Query e.g. the DATEDIFF function
should do the trick! Of course, now that you've taken the time to write
the SQL on the server, you may as well make it available to Excel via a
VIEW or PROCEDURE ...
Jamie.
--