How can i search a non case sensitive word with Sql Server XQuery?
-
09-06-2019 - |
Question
I'm using an Xml field in my Sql Server database table. I'm trying to search a word using the XQuery contains method but it seems to search only in case sensitive mode. The lower method isn't implemented on Sql Server XQuery implementation also. ¿Is there a simple solution to this problem?
Solution
If you're using SQL Server 2005, I'm afraid you're out of luck.
If you're using SQL Server 2008, you can use the upper-case function like this :
DECLARE @x xml = N'abcDEF!@4';
SELECT @x.value('fn:upper-case(/text()[1])', 'nvarchar(10)');
Here's a link on MSDN for the upper-case syntax and a couple search examples :
OTHER TIPS
First link from google points to MSDN page:
In order to get case-insensitive comparisons, the upper-case or lower-case functions can be used.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow