Skip to content

SQL Server: Exception when DISTINCT is used with result limited queries #963

Description

@kaizimmerm

Hi,

this change #300 unfortunately causes errors when the query is using distinct: com.microsoft.sqlserver.jdbc.SQLServerException: ORDER BY items must appear in the select list if SELECT DISTINCT is specified.

Maybe it is better not to try to trick the query parser here:

orderBy.add(statement.getBuilder().literal("ROW_NUMBER() OVER (ORDER BY (SELECT null))"));

...but step out in that case:

super.printSQLSelectStatement(call, printer, statement);
return;

Kai

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions