From fddad4669f7a9047c3d3f52e10b7101e3d9ee8ab Mon Sep 17 00:00:00 2001 From: Ansgar Becker Date: Wed, 28 Aug 2013 03:52:34 +0000 Subject: [PATCH] TOP(x) clause for UPDATES + DELETES introduced in MSSQL 2005. Do not use that on older servers. See http://www.heidisql.com/forum.php?t=13289 --- source/dbconnection.pas | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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;