--- moodle-1.9.4/lib/accesslib.php 2009-01-14 15:06:56.000000000 -0800 +++ moodle-edited/lib/accesslib.php 2009-02-13 14:20:01.000000000 -0800 @@ -1076,8 +1076,11 @@ ON inline_view.id = c.id"; /// To keep cross-db we need to strip any prefix in the ORDER BY clause for queries using UNION - $sql .= " - " . preg_replace('/[a-z]+\./i', '', $sort); /// Add ORDER BY clause + // To make sure it works properly in MSSQL, we need the prefixes. + if($CFG->dbtype !== 'mssql' && $CFG->dbtype !== 'mssql_n') { + $sql .= " + " . preg_replace('/[a-z]+\./i', '', $sort); /// Add ORDER BY clause + } $rs = get_recordset_sql($sql); }