T-SQL: Extracting values from XML

Pubblicato il: 02 novembre 2018
sul canale di: Alex D
1,487
7

FULL TSQL SCRIPT IS HERE: www.dargelis.net/idea/sql-scripts/XML_select.sql

DECLARE @xml_str xml
SET @xml_str='
?shiporder?
?orderid?889923?/orderid?
?orderperson?John Smith?/orderperson?
?shipto?
?name?Alexey?/name?
?address?Champ elysee 1?/address?
?city?Paris?/city?
?country?France?/country?
?/shipto?
?lines?
?item?
?product?Lager format printer?/product?
?note?Special Edition?/note?
?quantity?2?/quantity?
?price?1090?/price?
?/item?
?item?
?product?Big boxes?/product?
?quantity?100?/quantity?
?price?9.90?/price?
?/item?
?item?
?product?iPhone?/product?
?note?model X?/note?
?quantity?2?/quantity?
?price?1234.56?/price?
?/item?
?/lines?
?/shiporder?'

SELECT @xml_str.value('(/shiporder/shipto/city)[1]','varchar(50)') as one,
@xml_str.value('(/shiporder/lines/item/product)[1]','varchar(50)') as two,
@xml_str.value('(/shiporder/lines/item/product)[2]','varchar(50)') as three,
@xml_str.value('(/shiporder/lines/item/product)[3]','varchar(50)') as four,
(select T.c.value('local-name(.)', 'varchar(50)')
FROM @xml_str.nodes('/*') T(c)) as five


In questa pagina del sito puoi guardare il video online T-SQL: Extracting values from XML della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Alex D 02 novembre 2018, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 1,487 volte e gli è piaciuto 7 spettatori. Buona visione!