请检查此示例 SP
您需要为每一行创建类似于以下格式的 XML 并提供给 SQL ..
根据您的要求进行一些修改可能会解决您的问题..
/**************************************************************
EXEC wa_TempInsert '<SampleXML>
<tblRow><Id>3</Id><Code>11</Code><Description>Leptospiral infect NEC</Description></tblRow>
<tblRow><Id>3</Id><Code>22</Code><Description>Leptospiral infect NEC</Description></tblRow>
<tblRow><Id>3</Id><Code>33</Code><Description>Leptospiral infect NEC</Description></tblRow>
<tblRow><Id>3</Id><Code>44</Code><Description>Leptospiral infect NEC</Description></tblRow>
<tblRow><Id>3</Id><Code>55</Code><Description>Leptospiral infect NEC</Description></tblRow>
</SampleXML>'
*/
CREATE PROCEDURE wa_TempInsert
(
@XML NVARCHAR(MAX)
)
AS
SET NOCOUNT ON
BEGIN
DECLARE @Id INT
DECLARE @MyXML XML
SET @MyXML = @XML
IF OBJECT_ID('tempdb..#TempXMLTable') IS NOT NULL
DROP TABLE #TempICD
SELECT * INTO #TempICD
FROM (
SELECT
Parse.value('(Id)[1]', 'INT') AS 'Id',
Parse.value('(Code)[1]', 'Varchar(100)') AS 'Code',
Parse.value('(Description)[1]', 'varchar(1000)') AS 'Description'
FROM
@MyXML.nodes('/SampleXML/tblRow') AS TempData(Parse)
) AS tbl
INSERT INTO Table (Code,[Description],Id)
SELECT DISTINCT Code,[Description],Id FROM #TempXMLTable
END
END