Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6970403
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:42:20+00:00 2026-05-27T16:42:20+00:00

i want to save xml data into a table in sp,passed as string,here is

  • 0

i want to save xml data into a table in sp,passed as string,here is my code

alter PROCEDURE usp_be_insertXML 
-- Add the parameters for the stored procedure here
@xml varchar(1000) 

AS
BEGIN
DECLARE @idoc int
DECLARE @doc varchar(1000)
SET NOCOUNT ON;

EXEC sp_xml_preparedocument @idoc OUTPUT, @xml

BEGIN TRY       
INSERT INTO testing ([Name] ,[Fname] )
SELECT  Column1,Column2
FROM OPENXML (@idoc, 'NewDataSet/Sheet1', 1)
WITH ([Column1] [nvarchar](50),
[Column2] [nvarchar](50))

END TRY
BEGIN CATCH

END CATCH
EXECUTE sp_xml_removedocument @idoc
END

This inserts NULL only in table,any help?
and here is XML

 <NewDataSet>
    <Sheet1>
      <Column1>Name</Column1>
      <Column2>Fname</Column2>
    </Sheet1>
    <Sheet1>
      <Column1>khan</Column1>
      <Column2>dd</Column2>
    </Sheet1>
    <Sheet1>
      <Column1>mytest</Column1>
      <Column2>ff</Column2>
    </Sheet1>
 </NewDataSet> 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T16:42:21+00:00Added an answer on May 27, 2026 at 4:42 pm

    Problem is you’re specifying to use an “attribute-centric” mapping (the “1” in the last parameter of OPENXML), but your data elements are actually elements. You can get your desired result one of two ways:

    1) Change the parameter to “2”
    2) Change your WITH clause to explicitly state the child element you’re looking for:

    WITH (
    [Column1] [nvarchar](50) 'Column1'
    , [Column2] [nvarchar](50) 'Column2' 
    )  
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to save some XML formatted data into the Application Support folder, but
I want to save data from my database into xml file. I am using
I want to save and load my xml data using XmlReader. But I don't
I have a Java application that I want to save the data in XML
I want to save the data from a certain link in a xml file
I want to save a local copy of xml being ouput by a certain
i want to save a balance of user, in the user table . the
I want to save large amounts of text then display them (first in table
I am using jQuery to take data from an xml file and save it
i want to use XML to save some configuration for elements in my app.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.