New problem getting data from xml table in sql db (Newbie)


hello,

i have xml tablerow in table in db.

2 examples

<toyconfiguration version = "1" name = "lego">

<ballconfiguration version = "2020" name= "adidas">

if want name of toy or ball write

select

tablerow.value('((@name)[1]', 'varchar(100)')

from table

this return lego , adidas

but if want know kind of configuration is? how do this?

the answer want toyconfiguration , ballconfiguration..

any appreciated!

 

 

 

you use local-name() function:

select

tablerow.xml_col.value('(//@name)[1]', 'varchar(100)')

,tablerow.xml_col.value('local-name((*[@name])[1])', 'varchar(100)')

from tablerow



SQL Server  >  SQL Server XML



Comments

Popular posts from this blog

Motherboard replacement

Cannot create Full Text Search catalog after upgrading to V12 - Database is not fully started up or it is not in an ONLINE state

Remote Desktop App - Error 0x207 or 0x607