MS SQL Server: Select Distinct on text datatype

From: Matthias Moeser (matthia..sh.com.au)
Date: Mon Aug 04 2008 - 03:09:26 EDT

  • Next message: Andrey Razumovsky: "Re: MS SQL Server: Select Distinct on text datatype"

    Hi!

    We are using Cayenne with Microsoft SQL Server. We get a
    com.microsoft.sqlserver.jdbc.SQLServerException: "The text data type
    cannot be selected as DISTINCT because it is not comparable."

    The problem is that the following query is not allowed in MS SQL Server:

    SELECT DISTINCT column FROM table;

    where "column" is of datatype "text". So i think that cayenne does
    somewhere such a DISTINCT query on a "text" datatype column.

    The datatype "text" in MS SQL server is a variable-length data with a
    maximum length of 2^31 - 1 (2,147,483,647) characters, Varchar() can
    have only maximum 8000 character.

    What can I do? I need the "text" datatype.

    Thank you
    Matthias

    org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
    at
    org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.jav
    a:228)
    at
    org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.ja
    va:450)
    Caused by: java.lang.Exception: The text data type cannot be selected as
    DISTINCT because it is not comparable.
    com.microsoft.sqlserver.jdbc.SQLServerException: The text data type
    cannot be selected as DISTINCT because it is not comparable.
    at
    com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(Un
    known Source)
    at
    com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(Unknown
    Source)
    at
    com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePrepare
    dStatement(Unknown Source)
    at
    com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.
    doExecute(Unknown Source)
    at com.microsoft.sqlserver.jdbc.TDSCommand.execute(Unknown
    Source)
    at
    com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(Unknown
    Source)
    at
    com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(Unknown
    Source)
    at
    com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(Unknown
    Source)
    at
    com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeQuery(Unk
    nown Source)
    at
    org.apache.cayenne.access.jdbc.SelectAction.performAction(SelectAction.j
    ava:73)
    at
    org.apache.cayenne.access.DataNodeQueryAction.runQuery(DataNodeQueryActi
    on.java:58)



    This archive was generated by hypermail 2.0.0 : Mon Aug 04 2008 - 03:13:22 EDT