2013-08-22 59 views
0

我想使用包含符号符号的CONTAINS搜索,但我可以发现虽然表中有数据。我如何使用它,有没有补救办法?使用CONTAINS搜索带有“&”符号的特殊字符

如:

DECLARE @Author NVARCHAR(200) = N'&' 

SET @Author = '"' + REPLACE(@Author, ' ', '*" and "') + '*"' 

SELECT * 
FROM dbo.Taxonomy AS t (NOLOCK) 
WHERE CONTAINS(t.Author, @Author) 

但不返回结果:(

+0

只是象..谢谢 – DONER

+1

是你'Replace' funcion对你是唯一使用替换替换空格......并且在示例中'@ Author'中没有空格 –

+0

您能提供样本数据吗? –

回答

0

试试这个:

DECLARE @Author NVARCHAR(200) = N'"&"' 

SET @Author = '"' + REPLACE(@Author, ' ', '*" and "') + '*"' 

SELECT * 
FROM dbo.Taxonomy AS t (NOLOCK) 
WHERE CONTAINS(t.Author, @Author)