I Have a Problem in xml data importing Plese help me in this .
when i m insertning data through Application it is inserting but while I am using Store Procedure its giving the error
Running [dbo].[sp_xmlbulkinsert] ( @xmldata = D:\xml\rfid\Branches.xml, @table_name = Branches, @Action = xmlImport ).
The XML parse error 0xc00ce556 occurred on line number 1, near the XML text "D:\xml\rfid\Branches.xml".
The error description is 'Invalid at the top level of the document.'.
sp_xml_removedocument: The value supplied for parameter number 1 is invalid.
No rows affected.
And my SP is
Expand|Select|Wrap|Line Numbers
- set ANSI_NULLS ON
- set QUOTED_IDENTIFIER ON
- GO
- ALTER PROC [dbo].[sp_xmlbulkinsert]
- @xmldata varchar(max) =null,
- @table_name varchar(50),
- @Action varchar(50)
- AS
- Begin
- SET NOCOUNT ON
- if @Action='xmlImport'
- begin
- declare @statement varchar(200)
- DECLARE @hDoc int
- DECLARE @error INT
- exec sp_xml_preparedocument @hDoc OUTPUT, @xmldata
- set @statement ='Insert Into '+ @table_name +' '+ 'SELECT * FROM OPENXML('+ convert(varchar, @hDoc) +','+
- '''/NewDataSet/Table''' +',2) with '+ @table_name ;
- execute (@statement)
- EXEC sp_xml_removedocument @hDoc
- -- end
- end
- else if @Action='xmlExport'
- begin
- set @statement='Select * from '+ @table_name
- execute (@statement)
- end --'+convert(varchar,@hDoc)+ '
- end
---------
In @xmldata parameter I m Passing the Path D:\xml\rfid\Branches.xml is it correct or not
Please help me for this