From 1b23228d8b04c1232703987fbeb1b620d23cfada Mon Sep 17 00:00:00 2001 From: cxl Date: Mon, 20 Oct 2014 18:43:25 +0000 Subject: [PATCH] Sql: SqlExp: .Limit(n) in MSSQL emulated using TOP git-svn-id: svn://ultimatepp.org/upp/trunk@7805 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/Sql/SqlStatement.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/uppsrc/Sql/SqlStatement.cpp b/uppsrc/Sql/SqlStatement.cpp index ad74598c6..a087e6bda 100644 --- a/uppsrc/Sql/SqlStatement.cpp +++ b/uppsrc/Sql/SqlStatement.cpp @@ -115,7 +115,10 @@ SqlSelect& SqlSelect::NoWait() { } SqlSelect& SqlSelect::Limit(int limit) { - text << " limit " << limit; + ASSERT(text.StartsWith("select ")); + String s = AsString(limit); + text.Insert(6, SqlCase(MSSQL, " top " + s)()); + text << SqlCase(MSSQL, "")(" limit " + s); return *this; }