SQL Server 2008与SQL Server 2016中的特殊字符的差异 [英] Differences with Special Characters in SQL Server 2008 vs SQL Server 2016

查看:206
本文介绍了SQL Server 2008与SQL Server 2016中的特殊字符的差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


只是想知道任何人都可以解释SQL Server 2008和SQL Server 2016之间在使用特殊字符运行查询方面的
差异。我在2008年与2016年运行此查询时得到的结果完全不同。  




< p style ="color:#333333; font-size:11pt; font-family:Calibri,sans-serif; margin-bottom:0px">
例如:



价值






选择tx_title

来自来源

其中包含( (tx_title),'" Value(s)"')








解决方案

你好LorcanMc,


 


感谢您的发帖。


 


CONTAINS从SQL Server 2008开始。它搜索精确或模糊(不太精确)匹配单个单词和短语,彼此相距一定距离内的单词,或加权匹配
in SQL Server.CONTAINS是Transact-SQL SELECT语句的WHERE子句中使用的谓词,用于对包含基于字符的数据类型的全文索引列执行SQL Server全文搜索。


 


我不确定你说的是什么特殊字符。你的意思是Value(s)是一个字符串吗? 
有一个例子,它适用于SQL Server 2008及以上版本,请参考它。


https://docs.microsoft.com/en-us/sql/t-sql/queries/contains-transact-sql?view=sql-server-2017#c-using- contains-with-prefix_term


 


另外,要重现您的问题,您可以 
请与我们分享您的表结构和一些示例数据
(CREATE TABLE和INSERT INTO的脚本) 以及您的预期结果 这样我们才能获得正确的方向做一些测试。


 


最好的问候,


Rachel


Just wondering can anyone explain the difference between SQL Server 2008 and SQL Server 2016 in terms of running query with special characters. I'm getting totally different results when running this query in 2008 vs 2016.  

For example:

Value(s)


select tx_title
from source
where contains((tx_title), '"Value(s)"')




解决方案

Hi LorcanMc,

 

Thank you for your posting.

 

CONTAINS is starting with SQL Server 2008. It searches for precise or fuzzy (less precise) matches to single words and phrases, words within a certain distance of one another, or weighted matches in SQL Server. CONTAINS is a predicate used in the WHERE clause of a Transact-SQL SELECT statement to perform SQL Server full-text search on full-text indexed columns containing character-based data types.

 

And I am not sure what special characters you said is. Did you mean that Value(s) is a string?  There is an example and it will suit for SQL Server 2008 and above versions , please refer it .

https://docs.microsoft.com/en-us/sql/t-sql/queries/contains-transact-sql?view=sql-server-2017#c-using-contains-with-prefix_term

 

Also, to reproduce your problem, could you  please share us your table structure and some sample data (the script of CREATE TABLE and INSERT INTO)along with your expected result? So that we’ll get a right direction and make some test.

 

Best Regards,

Rachel


这篇关于SQL Server 2008与SQL Server 2016中的特殊字符的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆