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
Post a Comment