2

其中,stockView是帶有全文索引的索引視圖,我在下面收到錯誤消息。數據庫在2005兼容模式下運行在2008 Express引擎上。嘗試使用CTE對FREETEXTTABLE索引視圖執行嚴重錯誤

代碼:

with stockCte (title, grade, price, weighted) 
as 
(
    select sv.[title]     , 
      sv.[grade]     , 
      sv.[price]     , 
      (case when sv.[issue] = @issue and svs.[rank] > 30 
       then svs.[rank] + 100 
       else svs.[rank] 
       end)     weighted 
    from stockView sv 
    inner join freetexttable(stockView, (name), @term) svs 
     on sv.[id] = svs.[key] 
) 
select * from stockCte; 

錯誤:

Msg 0, Level 11, State 0, Line 0 
A severe error occurred on the current command. The results, if any, should be discarded. 
Msg 0, Level 20, State 0, Line 0 
A severe error occurred on the current command. The results, if any, should be discarded. 

當我取下內的查詢工作加入和加權列。任何想法,我都不知所措。

+0

我沒有看到任何東西離開我的頭頂。你做這個CTE而不是僅僅使用內部選擇的任何特定原因? – 2009-06-14 16:56:55

+0

內部選擇只是我開始,最終選擇將包括將通過CTE公開的分頁功能。 – kim3er 2009-06-14 17:22:03

回答

0

不情願,我已經訴諸使用表變量,而不是CTE。

declare @stockTemp table(
    title    nvarchar(100), 
    grade    nvarchar(50), 
    price    money, 
    row     bigint 
); 

insert into @stockTemp 
select sv.[title]     , 
     sv.[grade]     , 
     sv.[price]     , 
     row_number() over (order by (case when sv.[issue] = @issue and svs.[rank] > 30 
              then svs.[rank] + 100 
              else svs.[rank] 
              end) desc, 
             sv.title, 
             sv.grade desc, 
             sv.price asc) 
from stockView sv 
inner join freetexttable(stockView, (*), @term) svs 
    on sv.[id] = svs.[key] 

select * from @stockTemp; 

如果有人有任何更好的建議,請讓我知道。

0

錯誤級別11未找到數據庫對象; freetexttable查詢上的select是否可以作爲select?如果是這樣的完整查詢工作作爲一個選擇(沒有cte定義?)

1

它還沒有在R2中修復,但是它有一個修補程序 - 請參閱知識庫文章#2421014。

相關問題