Listing 4: OpenXML Example That Inserts into Multiple Tables from a Single XML Document DECLARE @h int DECLARE @xmldoc varchar(1000) set @xmldoc = ' ' EXEC sp_xml_preparedocument @h OUTPUT, @xmldoc INSERT INTO stores SELECT * FROM OpenXML(@h,'/root/stores') WITH stores INSERT INTO discounts SELECT * FROM OpenXML(@h,'/root/stores/discounts', 0) WITH discounts EXEC sp_xml_removedocument @h