如果stockView是带有全文索引的索引视图,我会收到以下错误消息。该数据库在2005 Express引擎上以2005兼容模式运行。
代码:
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 :(得分:1)
它也没有在R2中修复,但它有一个修补程序 - 请参阅知识库文章#2421014。
答案 1 :(得分:0)
错误级别11是未找到的数据库对象; freetexttable查询上的select是否可以作为选择?如果是,那么完整查询是否作为选择(没有cte定义?)
答案 2 :(得分: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;
如果有人有任何更好的建议,请告诉我。