sql

  • I Need uploading an XML file to SQL Server... The scipt should use MS SQL Server Bulk import capability (OpenXML)...How can i do this.

  • This was removed by the editor as SPAM

  • Try :

    CREATE

    TABLE xml_documents( x XML );

    INSERT

    INTO xml_documents ( x )

    SELECT * FROM OPENROWSET(BULK N'myXmlFile.xml', SINGLE_BLOB) AS x;

    GO

     

    More information on :

    http://blogs.msdn.com/stuartpa/archive/2005/07/19/440572.aspx

     

  • Try this :

    USE NorthWind

    CREATE PROC GetRegions_XML

     @empdata text

    AS

    begin

    DECLARE @hDoc int

    DECLARE @tbl TABLE(state VARCHAR(20))

    exec sp_xml_preparedocument @hDoc OUTPUT, @empdata  

    INSERT @tbl

    SELECT StateName

    FROM OPENXML(@hDoc, 'root/States')  

     WITH (StateName VARCHAR(20))

    EXEC sp_xml_removedocument @hDoc  

    SELECT * FROM Suppliers

    WHERE Region IN (SELECT * FROM @tbl)

    end

     

    Then, run this script :

    declare @S varchar(100)

    set @S = '<root><States StateName = "LA"/>

      <States StateName = "MI"/>

      <States StateName = "OR"/></root>'

    exec GetRegions_XML @S

     

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply