From bb3034eb263cf001be0ce002e4442b29dd2ed33f Mon Sep 17 00:00:00 2001
From: David M <davidmj@users.sourceforge.net>
Date: Wed, 30 Aug 2006 00:58:36 +0000
Subject: [PATCH] - Bug #4000

git-svn-id: file:///svn/phpbb/trunk@6332 89ea8834-ac86-4346-8a33-228a782c2dd0
---
 phpBB/search.php | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/phpBB/search.php b/phpBB/search.php
index a2feeab37c..d304e71f0d 100644
--- a/phpBB/search.php
+++ b/phpBB/search.php
@@ -956,10 +956,24 @@ $template->assign_vars(array(
 	'S_SELECT_SORT_DAYS'	=> $s_limit_days)
 );
 
-$sql = 'SELECT search_time, search_keywords
-	FROM ' . SEARCH_RESULTS_TABLE . '
-	WHERE search_keywords <> \'\'
-	ORDER BY search_time DESC';
+// Can't do comparisons w/ TEXT on MSSQL, CAST is good enough
+switch (SQL_LAYER)
+{
+	case 'mssql':
+	case 'mssql_odbc':
+		$sql = 'SELECT search_time, search_keywords
+			FROM ' . SEARCH_RESULTS_TABLE . '
+			WHERE CAST(search_keywords AS varchar) <> \'\'
+			ORDER BY search_time DESC';
+	break;
+
+	default:
+		$sql = 'SELECT search_time, search_keywords
+			FROM ' . SEARCH_RESULTS_TABLE . '
+			WHERE search_keywords <> \'\'
+			ORDER BY search_time DESC';
+	break;
+}
 $result = $db->sql_query_limit($sql, 5);
 
 while ($row = $db->sql_fetchrow($result))