Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Inserting data from an XML string in a table

Inserting data from an XML string in a table

Scheduled Pinned Locked Moved Database
helpsharepointdatabasexml
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • O Offline
    O Offline
    ONeil Tomlinson
    wrote on last edited by
    #1

    i wnat to inset the following data into a table. The data is an xml file as folows ------------- <root> <employee> <id>20</id> <fname>tom</fname> <lname>smith</lname> </employee> </root> --------------------- i have the follwoing stored procedure that takes the xml text as a parameter, insert the data and return the table data back to me - but im getting this error = "Incorrect syntax near the keyword 'FROM'" and "Incorrect syntax near the keyword 'with'. If this statement is a common table expression or an xmlnamespaces clause, the previous statement must be terminated with a semicolon." Help Please -------------------------------- set ANSI_NULLS ON set QUOTED_IDENTIFIER ON go create PROC [dbo].[sp_add_employee1] @empdata text AS DECLARE @hDoc int exec sp_xml_preparedocument @hDoc OUTPUT,@empdata INSERT into Employee (id, fname, lname) SELECT FROM OPENXML (@hDoc, '/root/Employee') WITH Employee (id varchar(50),fname varchar(50), lname varchar(50)) EXEC sp_xml_removedocument @hDoc SELECT * from Employee FOR XML AUTO -------------------------------------------

    W 1 Reply Last reply
    0
    • O ONeil Tomlinson

      i wnat to inset the following data into a table. The data is an xml file as folows ------------- <root> <employee> <id>20</id> <fname>tom</fname> <lname>smith</lname> </employee> </root> --------------------- i have the follwoing stored procedure that takes the xml text as a parameter, insert the data and return the table data back to me - but im getting this error = "Incorrect syntax near the keyword 'FROM'" and "Incorrect syntax near the keyword 'with'. If this statement is a common table expression or an xmlnamespaces clause, the previous statement must be terminated with a semicolon." Help Please -------------------------------- set ANSI_NULLS ON set QUOTED_IDENTIFIER ON go create PROC [dbo].[sp_add_employee1] @empdata text AS DECLARE @hDoc int exec sp_xml_preparedocument @hDoc OUTPUT,@empdata INSERT into Employee (id, fname, lname) SELECT FROM OPENXML (@hDoc, '/root/Employee') WITH Employee (id varchar(50),fname varchar(50), lname varchar(50)) EXEC sp_xml_removedocument @hDoc SELECT * from Employee FOR XML AUTO -------------------------------------------

      W Offline
      W Offline
      Wendelius
      wrote on last edited by
      #2

      ONeil Tomlinson wrote:

      SELECT FROM OPENXML (@hDoc, '/root/Employee')

      SELECT * FROM OPENXML (@hDoc, '/root/Employee')

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups