为什么我的 SQL 查询尝试将 nvarchar 值转换为 int? (使用 CONTAINSTABLE())
我正在尝试让全文搜索在 SQL Server 2008 R2 中运行。我一直在与我们的管理员合作,我们相信我们已经成功设置了索引的目录。现在,我尝试使用 FullText 函数查询索引表
。这可以正常工作:
select *
from mPages
where contains(bodytext, ' "a dog" ')
但是,当我尝试使用 containstable()
获取排名值时,出现错误。
select mPages.bodytext, KEY_TBL.RANK
from mPages
INNER JOIN
CONTAINSTABLE(mPages, bodyText,
'dog') AS KEY_TBL
ON mPages.pageID = KEY_TBL.[KEY]
ORDER BY KEY_TBL.RANK DESC;
错误:
Msg 245, Level 16, State 1, Line 2
Conversion failed when converting the nvarchar value 'About' to data type int.
“关于”值位于名为 pagename
的列中。我不明白如何让这个错误消失。
有什么帮助吗?
I am trying to get the FullText Search working in SQL Server 2008 R2. I have been working with our admin and we believe we have a catalog with indexes successfully set up. Now, I'm trying to query the indexed table using FullText functions
This works without a problem:
select *
from mPages
where contains(bodytext, ' "a dog" ')
However, when I try to get rank values by using containstable()
, I get an error.
select mPages.bodytext, KEY_TBL.RANK
from mPages
INNER JOIN
CONTAINSTABLE(mPages, bodyText,
'dog') AS KEY_TBL
ON mPages.pageID = KEY_TBL.[KEY]
ORDER BY KEY_TBL.RANK DESC;
Error:
Msg 245, Level 16, State 1, Line 2
Conversion failed when converting the nvarchar value 'About' to data type int.
The "About" value is in a column called pagename
. I don't understand how to get this error to go away.
Any help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它可能会抱怨这一行:
假设
pageID
是一个int
,它将尝试将key
转换为int
> 因此可以比较这些列。转换并未按计划进行。It's probably complaining about this line:
Assuming
pageID
is anint
, it will try to convert thekey
to anint
so the columns can be compared. The conversion is not going as planned.