0

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

Edited by mike_2000_17: Fixed formatting

2
Contributors
2
Replies
4
Views
8 Years
Discussion Span
Last Post by vuyiswamb
0

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.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.