July 9, 2017 at 5:34 am
hi,
In x query of sql-server, there is a function which can be called in two ways.
ex:
DECLARE @x xml = N'abcDEF!@4'; SELECT @x.value('fn:lower-case(/text()[1])', 'nvarchar(10)');
DECLARE @x xml = N'abcDEF!@4'; SELECT @x.value('lower-case(/text()[1])', 'nvarchar(10)');
q1) So please tel me which one should be used and when?
yours sincerely
July 9, 2017 at 6:06 am
rajemessage 14195 - Sunday, July 9, 2017 5:34 AMhi,In x query of sql-server, there is a function which can be called in two ways.
ex:
DECLARE @x xml = N'abcDEF!@4'; SELECT @x.value('fn:lower-case(/text()[1])', 'nvarchar(10)');
DECLARE @x xml = N'abcDEF!@4'; SELECT @x.value('lower-case(/text()[1])', 'nvarchar(10)');
q1) So please tel me which one should be used and when?
yours sincerely
My suggestion is to use neither, use the LOWER function instead, much more efficient. This and other functions are implemented using an additional constant scan and a merge join, skipping the XML function eliminates those operators from the execution plan.
😎SELECT LOWER(@x.value('(/text())[1]', 'nvarchar(10)'));
There is no real difference between the two, if you need to use the XML function then use the fn:lower-case syntax, just in case there are other libraries with a function with the same name.
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply