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 9001547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:27:04+00:00 2026-06-16T00:27:04+00:00

I wrote the following procedure to do bulk insert using openxml. The table name

  • 0

I wrote the following procedure to do bulk insert using openxml. The table name and column names are dynamic in my case as they will be created from .Net application just before this below insert. The stored procedure is running successfully but not inserting any data into the table.

Please help me

Thanks in advace.

CREATE PROCEDURE [dbo].[BulkUpdate]
@XmlDoc text,
@TableName nvarchar(50),
@ColumnNames nvarchar(4000),
@ColumnDefinition nvarchar(4000)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
Declare @Idoc int;
Declare @Sql nvarchar(4000);
BEGIN TRANSACTION
Begin Try
Exec sp_xml_preparedocument @Idoc output, @XmlDoc;

Set @Sql = 'Insert into '+@TableName+'('+@ColumnNames+')

Select '+@ColumnNames+' From OpenXML(@Idoc,''/NewDataSet/Data'', 2)

With('+@ColumnDefinition+')';

Print @sql;
Exec @Sql;

Exec sp_xml_removedocument @Idoc;
Commit Transaction
End Try
Begin Catch
RollBack Transaction
End Catch

END
  • 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-06-16T00:27:05+00:00Added an answer on June 16, 2026 at 12:27 am

    I observed that SqlClient.BulkCopy as the better performant than the above OpenXML approach. Hence I changed my logic accordingly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote a package to query rows from a table. This select query will
I wrote the following stored procedure: ALTER PROCEDURE [dbo].[spLinkAssetToModule] ( -- Add the parameters
I wrote a long stored procedure, when I call it i receive the following
I wrote a stored procedure and created a temp table #TempHitRatioTable. I forgot to
I am creating a stored procedure which has to create a table which name
I have the following PL/SQL block that creates a procedure to insert a new
I wrote the following stored procedure, in which I use a local variable 'syncParam':
I wrote the following code: procedure MouseWheel(var Msg:TWMMouseWheel);message WM_MOUSEHWHEEL; I used it for a
I have a table A with an Identity column. When I insert a row
I wrote following stored procedure in SQL Server 2005 and I get error message:

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.