diff --git a/src/mod_mam_sql.erl b/src/mod_mam_sql.erl index 2747254ac..71420c9ea 100644 --- a/src/mod_mam_sql.erl +++ b/src/mod_mam_sql.erl @@ -221,6 +221,10 @@ delete_old_messages_batch(ServerHost, TimeStamp, Type, Batch) -> ejabberd_sql:sql_query_t( ?SQL("delete from archive where rowid in " "(select rowid from archive where timestamp < %(TS)d and %(ServerHost)H limit %(Batch)d)")); + (mssql, _) -> + ejabberd_sql:sql_query_t( + ?SQL("delete top(%(Batch)d)ยง from archive" + " where timestamp < %(TS)d and %(ServerHost)H")); (_, _) -> ejabberd_sql:sql_query_t( ?SQL("delete from archive" @@ -236,6 +240,12 @@ delete_old_messages_batch(ServerHost, TimeStamp, Type, Batch) -> " select rowid from archive where timestamp < %(TS)d" " and kind=%(SType)s" " and %(ServerHost)H limit %(Batch)d)")); + (mssql, _)-> + ejabberd_sql:sql_query_t( + ?SQL("delete top(%(Batch)d) from archive" + " where timestamp < %(TS)d" + " and kind=%(SType)s" + " and %(ServerHost)H")); (_,_)-> ejabberd_sql:sql_query_t( ?SQL("delete from archive"