| Код | DECLARE @XML_Ptr INT DECLARE @InXML XML = '<recipe> <composition> <ingredient amount="3" unit="стакан">Мука</ingredient> <ingredient amount="0.25" unit="грамм">Дрожжи</ingredient> <ingredient amount="1.5" unit="стакан">Тёплая вода</ingredient> <ingredient amount="1" unit="чайная ложка">Соль</ingredient> </composition> <composition> <ingredient amount="1" unit="стакан1">Мука</ingredient> <ingredient amount="2" unit="грамм2">Дрожжи</ingredient> <ingredient amount="3" unit="стакан3">Тёплая вода</ingredient> <ingredient amount="4" unit="чайная ложка4">Соль</ingredient> </composition> </recipe>' EXEC sp_xml_preparedocument @XML_Ptr OUTPUT, @InXML
SELECT recipe.rec FROM OPENXML (@XML_Ptr, '/recipe/composition', 2) WITH ( rec XML '../composition' ) recipe
|
| Код |
Пытаюсь переделать на nodes: SELECT T.c.value('../composition[1]', 'xml' ) AS rec FROM @InXML.nodes('/recipe/composition') T(c)
|
The data type 'xml' used in the VALUE method is invalid.
Возможно ли как-то по-другому вывести данные в формате xml? |