Hi,
I was trying to come up with a good way of specifying TOP 1 or LIMIT 1 when using SQL Server or PostgreSQL DB's.
For now I have defined macros {TOP_1} and {LIMIT_1} and a typical query look like this:
SELECT {TOP_1} ID FROM SOME_TABLE {LIMIT_1}
Where {TOP_1} is defined for SQL Server and {LIMIT_1} is defined for PostgreSQL.
This isn't very clever for TOP 5 or LIMIT 10 though...
Is there a clever way to do it?
Thanks in advance,
Regards, Paul.
Unified SQL for TOP n or LIMIT n
Hello
You should write your query like this:
In this case the "TOP_MACROS" and "LIMIT_MACROS" will be replaced by your value and string after space ("5") will be added in the end. You can find more detailed information about this in the Unified SQL section of the UniDAC help.
You should write your query like this:
Code: Select all
SELECT {TOP_MACROS 5} ID FROM SOME_TABLE {LIMIT_MACROS 5}