Good Day all

I have a Sp that is written like this

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go




ALTER PROCEDURE [dbo].[Import_RegistrationsXM] @xml ntext

AS

set nocount on

DECLARE @doc int
EXEC sp_xml_preparedocument @doc OUTPUT, @xml  

TRUNCATE TABLE _RegistrationXM
INSERT INTO _RegistrationXM
SELECT * 
FROM OPENXML ( @doc , 'Import/Item' , 2) 
WITH (  
    Student varchar(32),
    SubjectCode varchar(32),
    Campus varchar(32),
    Repeat bit
)
EXEC sp_xml_removedocument @doc

truncate table _Duplicates

exec( 'sp_RegistrationsXM_Populate' )

select 'XM Registrations successfully imported!' [Result]

i have an XML File that is 3.21mb, when i this Sp with the XML i get the Following Error

Exception caught in: ExecuteStoredProc: Cannot insert duplicate key row in object 'dbo._RegistrationXM' with unique index '_RegistrationXM_index'. The statement has been terminated. [/pre]

in the table _RegistrationXM there are no Records and in the File there are no Duplicates too.

Thank you

Recommended Answers

All 2 Replies

This error means that there should be a unique index for some field in _RegistrationXM table.

Therefore check any duplicate value is found in the XML data for that field.

Either remove unique index for that field(s) or remove duplicate data for the column(s) in the XML.

Thank you that was the Reason

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.