Batch Insert Data Solution (XML version)

xiaoxiao2021-04-01  231

The parameter format should be an XML format.

Store procedure:

Create Procedure XMlinsert

@XmlText Text

AS

Declare @intdoc int

Exec sp_xml_preparedocument @intdoc output, @xmltext

INSERT TEST1 ([Name], SEX)

Select [name], [SEX]

From OpenXML (@intdoc, '/ newdataset / table1')

With ([Name] varchar (100) 'name',

[SEX] VARCHAR (4) 'SEX')

EXEC SP_XML_REMOVEDOCUMENT @intdoc

Go

EXAMPLE:

C #:

DataSet DS = Your data source;

Call stored procedure (XMLInsert)

Add parameters (DS.GETXML ​​())

Ok! ~~

转载请注明原文地址:https://www.9cbs.com/read-131113.html

New Post(0)