对WITH语句内的视图进行全文搜索

时间:2012-05-23 09:10:43

标签: sql sql-server sql-server-2008 tsql common-table-expression

我有以下问题。执行下面的查询时,我收到以下错误:

  

消息0,级别11,状态0,行0发生严重错误   当前命令。结果(如果有的话)应该被丢弃。消息0,   20级,状态0,0行电流发生严重错误   命令。结果(如果有的话)应该被丢弃。

WITH PagingRows AS 
    ( 
        Select 
            ROW_NUMBER() Over (Order By LastName ASC) As Row,AddressBookId 
        FROM 
            AccountView  
        WHERE 
        (
            [AccountView].[AddressBookId] IN 
            (
               SELECT [key] FROM CONTAINSTABLE([AccountView],*,'"searchword*" ')
            )
        )
    ) 
    Select 
        [t0].*
    From
        PagingRows c    
        Inner Join AccountView t0 on c.AddressBookId = t0.AddressBookId 
    Where 
        c.Row Between 0 + 1 AND 0 + 50 
    Order By c.Row Asc FOR XML AUTO, ELEMENTS XSINIL

“AccountView”是一个全文索引的视图。查询的某些部分也可以单独使用。 由于下面的查询确实执行没有问题。

SELECT 
    ROW_NUMBER() Over (Order By LastName ASC) As Row,AddressBookId 
FROM 
    AccountView  
WHERE 
    [AccountView].[AddressBookId] IN (
        SELECT [key] FROM CONTAINSTABLE([AccountView],*,'"searchword*" ')
    )

如果“AccountView”视图被表替换,则查询可以正常工作。 我想知道如何解决这个问题,以及错误的原因是什么。

1 个答案:

答案 0 :(得分:2)

此问题有一个修补程序可用:KB 2421014