Link to home
Start Free TrialLog in
Avatar of Jim Horn
Jim HornFlag for United States of America

asked on

SQL Server XML .Value query returns NULL, should return a value

< Highly mocked up SQL Server 2008R2 T-SQL >
DECLARE @x XML 
SET @x = '<goo xmlns="http://underdog.com" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
  <foo>
    <boo>banana</boo>
  </foo>
</goo>'
SELECT @x.value('(/goo/foo/boo)[1]', 'varchar(64)') AS the_amount

Open in new window


I'm expecting to return a the_amount value of 'banana', but I'm always getting NULL.  What's the fix?
ASKER CERTIFIED SOLUTION
Avatar of zc2
zc2
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jim Horn

ASKER

Thanks.