0

How to manipulate the language attribute value in the following example, say to select EN1.

DECLARE @xml XML

SET @xml = N'<email><account language="English" /></email>'

SELECT T.C.value('@language', 'nvarchar(100)')
FROM @xml.nodes('email/account') T(C)

I am thinking something like this

SELECT T.C.value(CONCAT(SUBSTRING(@language, 1,2), '1'), 'nvarchar(100)')
FROM @xml.nodes('email/account') T(C)
InquisitiveLad
  • 309
  • 3
  • 16
  • 1
    `CONCAT` and `SUBSTRING` should be **around** the expression using the `value` method , not inside the method. – Thom A Jul 01 '22 at 12:38

1 Answers1

0

Many thanks to @Larnu, the following worked

SUBSTRING(SELECT T.C.value('@language', 'nvarchar(100)'), 1,2) + '1'
FROM @xml.nodes('email/account') T(C)
InquisitiveLad
  • 309
  • 3
  • 16