diff --git a/question/restorelib.php b/question/restorelib.php
index ca8d940..0f817aa 100644
--- a/question/restorelib.php
+++ b/question/restorelib.php
@@ -605,8 +605,12 @@
             //mappings in backup_ids to use them later where restoring states (user level).
 
             //Get the answer from DB (by question and answer)
-            $db_answer = get_record ("question_answers","question",$new_question_id,
-                                                    "answer",$answer->answer);
+            if (in_array($CFG->dbfamily, array('mssql', 'oracle'))) {
+                $db_answer = get_record_select('question_answers', "question = '{$new_question_id}' AND answer LIKE '{$answer->answer}'");
+            } else {
+                $db_answer = get_record ('question_answers','question',$new_question_id,
+                                                            'answer',$answer->answer);
+            }
 
             //Do some output
             if (($i+1) % 50 == 0) {
diff --git a/question/type/match/questiontype.php b/question/type/match/questiontype.php
index 5132f2a..be5254b 100644
--- a/question/type/match/questiontype.php
+++ b/question/type/match/questiontype.php
@@ -544,6 +544,8 @@ class question_match_qtype extends default_questiontype {
 
     function restore_map($old_question_id,$new_question_id,$info,$restore) {
 
+        global $CFG;
+
         $status = true;
 
         //Get the matchs array
@@ -571,9 +573,15 @@ class question_match_qtype extends default_questiontype {
             //mappings in backup_ids to use them later where restoring states (user level).
 
             //Get the match_sub from DB (by question, questiontext and answertext)
-            $db_match_sub = get_record('question_match_sub', 'question', $new_question_id,
-                    sql_compare_text('questiontext', 255), $match_sub->questiontext,
-                    'answertext', $match_sub->answertext);
+            if (in_array($CFG->dbfamily, array('mssql', 'oracle'))) {
+                $db_match_sub = get_record_select('question_match_sub', "question = '{$new_question_id}'
+                                                                     AND questiontext LIKE '{$match_sub->questiontext}'
+                                                                     AND answertext = '{$match_sub->answertext}'");
+            } else {
+                $db_match_sub = get_record('question_match_sub', 'question', $new_question_id,
+                        'questiontext', $match_sub->questiontext,
+                        'answertext', $match_sub->answertext);
+            }
             //Do some output
             if (($i+1) % 50 == 0) {
                 if (!defined('RESTORE_SILENTLY')) {
