diff --git a/sql_server/pyodbc/compiler.py b/sql_server/pyodbc/compiler.py index 8f70cd69..def2e13e 100644 --- a/sql_server/pyodbc/compiler.py +++ b/sql_server/pyodbc/compiler.py @@ -241,7 +241,8 @@ def as_sql(self, with_limits=True, with_col_aliases=False): # SQL Server requires the backend-specific emulation (2008 or earlier) # or an offset clause (2012 or newer) for offsetting - if do_offset: + # Additionally support "limit" for queries that use UNION, EXCEPT + if do_offset or (combinator and high_mark): if do_offset_emulation: # Construct the final SQL clause, using the initial select SQL # obtained above.