ERROR: Failed to search for papers!

<faer:error xmlns:faer="http://www.factmanager.com/factanswer/2003/04/error" title="Failed to serve a request">com.iimg.factanswer3.core.FactAnswerException: Failed to execute a prepared statement: create table #mypapers ( recid int identity(1,1) primary key, paperid int, alfaSort varchar(32), numSort float ) create table #mypapers2 ( recid int identity(1,1) primary key, paperid int ) insert into #mypapers (paperid, alfaSort, numSort) select paperid, alfaSort = case ? when 'title' then cast(title as varchar(32)) else '' end, numSort = case ? when 'paperid' then refno when 'status' then status when 'score' then AvgScore when 'year' then SiteId else '' end from tblPapers where (status &gt;= 140) and (SiteId in (select SiteId from tblConferenceYears where Status &gt; 1)) and (? = '' or paperid in (select paperid from tblCategoryPaper where categoryid in (select CategoryId from tblCategories where code = ?))) and (? = '' or paperid in (select paperid from tblCategoryPaper where categoryid in (select CategoryId from tblCategories where code = ?)) ) and (? = '' or authorid in (select userid from tblUsers where charindex(?, firstname) &gt; 0 or charindex(?, lastname) &gt; 0 or charindex(?, firstname + ' ' + lastname) &gt; 0) or PaperId in (select PaperId from tblCoAuthors where PersonId in (select PersonId from tblPersons where charindex(?, firstname) &gt; 0 or charindex(?, lastname) &gt; 0 or charindex(?, firstname + ' ' + lastname) &gt; 0) ) ) and (? = '' or charindex(?, title) &gt; 0) and (? = '' or SiteId in (select SiteId from tblConferenceYears where ConferenceYearId = ?)) order by alfaSort asc, numSort asc, refno desc insert into #mypapers2 (paperid) select paperid from #mypapers order by recid * ? select tblPapers.PaperId, Title, AuthorId, Status, IssueId, IssueOrder, AvgScore, RefNo, tblPapers.SiteId, (select count(*) from #mypapers2) as PaperCount from tblPapers inner join #mypapers2 on tblPapers.paperid = #mypapers2.paperid where recid &gt;= ? and recid - ? &lt; ? order by recid drop table #mypapers drop table #mypapers2 at com.iimg.factanswer3.provider.jdbc.JDBCStatement.get(JDBCStatement.java:291) at com.iimg.factanswer3.provider.jdbc.JDBCRequestDefinition.get(JDBCRequestDefinition.java:81) at com.iimg.factanswer3.provider.SimpleDataSource.serveRequest(SimpleDataSource.java:105) at com.iimg.factanswer3.provider.SimpleDataSource.run(SimpleDataSource.java:78) Caused by: java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Error converting data type varchar to numeric. at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source) at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source) at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processErrorToken(Unknown Source) at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReplyToken(Unknown Source) at com.microsoft.jdbc.sqlserver.tds.TDSRPCRequest.processReplyToken(Unknown Source) at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReply(Unknown Source) at com.microsoft.jdbc.sqlserver.SQLServerImplStatement.getNextResultType(Unknown Source) at com.microsoft.jdbc.base.BaseStatement.getNextResultType(Unknown Source) at com.microsoft.jdbc.base.BaseStatement.executeQueryInternal(Unknown Source) at com.microsoft.jdbc.base.BasePreparedStatement.executeQuery(Unknown Source) at com.iimg.factanswer3.provider.jdbc.JDBCStatement.get(JDBCStatement.java:288) ... 3 more </faer:error>