尝试使用 CTE FREETEXTTABLE 索引视图时出现严重错误

发布于 2024-07-25 09:12:52 字数 951 浏览 8 评论 0原文

当 stockView 是带有全文索引的索引视图时,我收到以下错误消息。 该数据库在 2008 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.

当我删除内部联接和加权列时,查询有效。 任何想法,我都不知所措。

Where stockView is an indexed view with a full-text index, I receive the error message below. The database is running on a 2008 Express engine in 2005 compatibility mode.

Code:

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;

Error:

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.

The query works when I remove the inner join and the weighted column. Any ideas, I'm at a loss.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

哑剧 2024-08-01 09:12:52

我很不情愿地使用表变量而不是 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;

如果有人有更好的建议,请告诉我。

Reluctantly I have resorted to using a table variable instead of a 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;

If anyone has any better suggestions, please let me know.

遇到 2024-08-01 09:12:52

R2 中也没有修复此问题,但有一个修补程序 - 请参阅知识库文章 #2421014。

It hasn't been fixed in R2 either, but there is a hotfix for it - see KB article #2421014.

终止放荡 2024-08-01 09:12:52

错误级别 11 是未找到数据库对象; freetexttable 查询上的 select 是否作为 select 工作? 如果是这样,完整查询是否作为选择工作(没有 cte 定义?)

Error Level 11 is database object not found; does the select on the freetexttable query work as a select ? If so does the full query work as a select (without the cte definition?)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文