Reading XML File

  • Hi

    I want to read and process an xml file from a specified physical location in the disk using stored procedure.Is there any way to do this ? .Would like to get your help.

    Thanks in advance

    Tomgy Varghese

  • I played around with it for personal interest sake.

    CREATE TABLE #tmp( XMLContainer TEXT)

    INSERT #tmp

    exec master.dbo.xp_cmdshell 'type myfile.xml'

    Once you have done this then you can use the built in SQL XML extensions to play around with your file.

  • Hi

    Thank you for your reply.

    I tried your solution, but i am getting following results when i select rows from #tmp table.please advice

    My Statements

    ----------------

    CREATE TABLE #tmp( XMLContainer TEXT)

    INSERT #tmp

    exec master.dbo.xp_cmdshell 'c:\specialticket.xml'

    select * from #tmp

    Output

    ---------

    'c:\specialticket.xml' is not recognized as an internal or external command,

    operable program or batch file.

    NULL

  • exec master.dbo.xp_cmdshell 'c:\specialticket.xml'

    should be

    exec master.dbo.xp_cmdshell 'type c:\specialticket.xml'

    What you are doing is executing a DOS type command but instead of the output being echoed to the screen it is being returned as the result set for the extended stored procedure and therefore imported into your temporary table.

  • Hi

          It is working now .Thank you very much

    Tomgy

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

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