The Best Way to shred XML data into SQL Server database columns

后端 未结 8 1718
萌比男神i
萌比男神i 2020-11-28 02:58

What is the best way to shred XML data into various database columns? So far I have mainly been using the nodes and value functions like so:

INSERT INTO some         


        
8条回答
  •  一整个雨季
    2020-11-28 03:26

    I'm not sure what is the best method. I used OPENXML construction:

    INSERT INTO Test
    SELECT Id, Data 
    FROM OPENXML (@XmlDocument, '/Root/blah',2)
    WITH (Id   int         '@ID',
          Data varchar(10) '@DATA')
    

    To speed it up, you can create XML indices. You can set index specifically for value function performance optimization. Also you can use typed xml columns, which performs better.

提交回复
热议问题