简体   繁体   English

为什么我的SQL查询试图将nvarchar值转换为int? (使用CONTAINSTABLE())

[英]Why is my SQL query trying to convert an nvarchar value to int? (using CONTAINSTABLE())

I am trying to get the FullText Search working in SQL Server 2008 R2. 我正在尝试让全文搜索在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 现在,我正在尝试使用FullText函数查询索引表

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. 但是,当我尝试使用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;

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 . “关于”值位于名为pagename的列中。 I don't understand how to get this error to go away. 我不知道如何解决此错误。

Any help? 有什么帮助吗?

It's probably complaining about this line: 可能是在抱怨这一行:

ON mPages.pageID = KEY_TBL.[KEY]

Assuming pageID is an int , it will try to convert the key to an int so the columns can be compared. 假设pageID是一个int ,它将尝试将key转换为int以便可以比较各列。 The conversion is not going as planned. 转换未按计划进行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM