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

Sam*_*yon 2 t-sql sql-server delphi adodb sql-server-express

我有以下查询:

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
Run Code Online (Sandbox Code Playgroud)

在SQL Server 2008 R2 Developer(无论如何),SQL Server 2005 Express和使用管理工作室的SQL Server 2008 R2 Express(最后两项工作)中运行时,执行查询时没有问题.但是一旦我尝试使用Delphi中的ADODB执行此查询,我就会收到错误消息.

Incorrect syntax near the keyword WITH
Run Code Online (Sandbox Code Playgroud)

SQL的快速版本中是否禁止这些查询?查询中的问题是什么?客户端使用SQL express,所以我需要找到一个解决这个问题的解决方案,该解决方案在快速版本中运行.

Pet*_*ang 8

我不知道它是否有帮助,但你可以尝试在查询之前加一个分号:

; WITH cte AS (
...
Run Code Online (Sandbox Code Playgroud)