简体   繁体   English

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

[英]Query (SQL Server 2008 Express) works in SQL Server Management Studio but not in Delphi using ADODB

I have the following query: 我有以下查询:

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

The query is executed without problems when running in SQL Server 2008 R2 Developer (no matter how), SQL Server 2005 Express and SQL Server 2008 R2 Express using the management studio (this work for the last two). 在SQL Server 2008 R2 Developer(无论如何),SQL Server 2005 Express和使用管理工作室的SQL Server 2008 R2 Express(最后两项工作)中运行时,执行查询时没有问题。 But as soon as I try to execute this queries using ADODB from Delphi I get an error saying. 但是一旦我尝试使用Delphi中的ADODB执行此查询,我就会收到错误消息。

Incorrect syntax near the keyword WITH

Are these kind of queries disallowed in the express versions of SQL? SQL的快速版本中是否禁止这些查询? what is the problem in the query? 查询中的问题是什么? The client uses SQL express, so I need to find a solution with this problem which runs in the express version. 客户端使用SQL express,所以我需要找到一个解决这个问题的解决方案,该解决方案在快速版本中运行。

I don't know if it helps, but you could try to put a semicolon before your query: 我不知道它是否有帮助,但你可以尝试在查询之前加一个分号

; WITH cte AS (
...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM