代码之家  ›  专栏  ›  技术社区  ›  Sambatyon

查询(SQL Server 2008 Express)在SQL Server Management Studio中工作,但在使用ADODB的Delphi中不工作。

  •  2
  • Sambatyon  · 技术社区  · 15 年前

    我有以下问题:

    WITH cte AS (
        SELECT
            windowId, frameIndx, elemIndx, comment, 
            ROW_NUMBER() OVER (PARTITION BY frameIndx ORDER BY elemIndx DESC)
        AS
            rn
        FROM
            dbo.translations
        WHERE
            windowId = 1 AND frameIndx IN (
                SELECT
                    indx
                FROM
                    dbo.translations_window
                WHERE program_id = 1 AND active = 1
        )
    )
    SELECT
        windowId, frameIndx, elemIndx, comment
    FROM
        cte
    WHERE
        rn = 1
    

    使用Management Studio在SQL Server 2008 R2 Developer(无论如何)、SQL Server 2005 Express和SQL Server 2008 R2 Express中运行时,执行查询时不会出现问题(这适用于最后两个)。但是一旦我尝试使用来自Delphi的ADODB执行这个查询,我就会得到一个错误消息。

    Incorrect syntax near the keyword WITH
    

    在SQL的Express版本中是否不允许使用这些查询?查询中的问题是什么?客户端使用SQL Express,因此我需要找到一个在Express版本中运行的解决方案。

    1 回复  |  直到 15 年前
        1
  •  8
  •   Community Mohan Dere    9 年前

    put a semicolon

    ; WITH cte AS (
    ...