SQL Server 2005和Datanucleus问题(ntext查询)

时间:2010-10-10 10:29:57

标签: sql-server eclipse sql-server-2005 datanucleus

开始使用SQL Server 2005获取错误

这是我第一次使用Datanucleus 2.x测试我们的应用程序(最后一次测试是使用DN 1.x进行的)

我使用Eclipse RCP。

Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: The ntext data type cannot be selected as DISTINCT because it is not comparable.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:197)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1493)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPrepared
Statement.java:390)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(SQLServerPreparedStatement.java:340)
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:4575)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1400)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:179)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:154)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeQuery(SQLServerPreparedStatement.java
:283)
at org.datanucleus.store.rdbms.SQLController.executeStatementQuery(SQLController.java:463)
at org.datanucleus.store.rdbms.query.JDOQLQuery.performExecuteInternal(JDOQLQuery.java:755)
... 5 more

1 个答案:

答案 0 :(得分:0)

正如第一行提到的那样,你试图对其中包含ntext类型字段的结果集进行DISTINCT ..这是不可能的..

查看Is there any way to DISTINCT or group by a text (or ntext) in SQL Server 2005?可能的解决方案。 (将字段强制转换为nvarchar(max)