none
Bulk Update into SQL Server Table from XML String RRS feed

  • Question

  • Hi All,

     

    Here, I published one Good thing for Bulk Insert or Update in table with XML Data

     

    =========Update SQL Server Table With XML Data ==========================

     

    Create PROCEDURE [dbo].[SPNAME]

    @paXmlStringIn xml

    AS

    BEGIN

    SET NOCOUNT ON

    DECLARE @XMLDocPointer INT

    EXEC sp_xml_preparedocument @XMLDocPointer OUTPUT, @paXmlStringIn

    UPDATE

    TargetTableName

    SET

    TargetTableName.ColumnName1 = XmlTable.ColumnName1,

    TargetTableName.ColumnName2 = XmlTable.ColumnName2,

    FROM

    OPENXML(@XMLDocPointer,'/XMLRoot/XMLRow',2)

    WITH (ColumnName1 ColumnDataType, ColumnName2 ColumnDataType) XmlTable

    WHERE TargetTableName.Column3 = XmlTable.Column3

    END

    EXEC sp_xml_removedocument @XMLDocPointer

     

    If @@ROWCOUNT > 0

    BEGIN

    SELECT 0 AS RESULT

    END

    ELSE

    SELECT 1 AS RESULT

     

     

     

     

     

     

     

     

     

     

     

     

     

    Wednesday, September 5, 2007 9:25 AM