Existuje nějaký konkrétní důvod, proč k tomu musíte použít OPENXML? Informace můžete snadno získat pomocí XQUERY v roce 2005 takto:
declare @xmldata xml
set @xmldata =
'<data xmlns="http://www.aaa.com/master_browse_response" xmlns:dt="http://www.aaa.com/DataTypes">
<products>
<product>
<product_id>121403</product_id>
<countries>
<dt:country>GBR</dt:country>
<dt:country>USA</dt:country>
</countries>
</product>
</products>
</data>'
;WITH XMLNAMESPACES
(
DEFAULT 'http://www.aaa.com/master_browse_response',
'http://www.aaa.com/DataTypes' as dt
)
SELECT x.c.value('(../../product_id)[1]', 'varchar(100)') as product_id,
x.c.value('(.)[1]', 'varchar(100)') as country
FROM @xmldata.nodes('/data/products/product/countries/dt:country') x(c)
Novější možnosti XQUERY jsou mnohem lepší volbou pro řešení vašeho problému.
EDIT:Stejné řešení s OPENXML by bylo:
declare @xmldata xml
set @xmldata =
'<data xmlns="http://www.aaa.com/master_browse_response" xmlns:dt="http://www.aaa.com/DataTypes">
<products>
<product>
<product_id>121403</product_id>
<countries>
<dt:country>GBR</dt:country>
<dt:country>USA</dt:country>
</countries>
</product>
</products>
</data>'
DECLARE @hDoc int, @rootxmlns varchar(100)
SET @rootxmlns = '<root xmlns:hm="http://www.aaa.com/master_browse_response" xmlns:dt="http://www.aaa.com/DataTypes"/>'
EXEC sp_xml_preparedocument @hDoc OUTPUT, @xmldata, @rootxmlns
SELECT *
FROM OPENXML(@hDoc, '//hm:product/hm:countries/dt:country',2)
WITH(Country varchar(100) '.',
Product_ID varchar(100) '../../hm:product_id')
EXEC sp_xml_removedocument @hDoc