diff --git a/source/dbconnection.pas b/source/dbconnection.pas index 0f543d15..032e6ae9 100644 --- a/source/dbconnection.pas +++ b/source/dbconnection.pas @@ -3739,9 +3739,11 @@ begin Result := QueryType + ' '; case FParameters.NetTypeGroup of ngMSSQL: begin - if QueryType = 'UPDATE' then - Result := Result + 'TOP('+IntToStr(Limit)+') ' - else if QueryType = 'SELECT' then + if QueryType = 'UPDATE' then begin + // TOP(x) clause for UPDATES + DELETES introduced in MSSQL 2005 + if ServerVersionInt >= 900 then + Result := Result + 'TOP('+IntToStr(Limit)+') '; + end else if QueryType = 'SELECT' then Result := Result + 'TOP '+IntToStr(Limit)+' '; Result := Result + QueryBody; end;