I'm trying to upload XML into SQL Server 2000. I've never used openxml and I'm struggling with it. Below is the procedure with data. -
DECLARE @idoc int
-
-
DECLARE @doc varchar (1000)
-
-
SET @doc ='
-
<Root>
-
<MajorFamily>
-
<FamilyName>CSSP Essential SW</FamilyName>
-
<MinorFamily>
-
<FamilyName>CSSP Ess SW for CallMgr Series Products</FamilyName>
-
<ProductNumber>CON-SESW-SBCSEU</ProductNumber>
-
</MinorFamily>
-
</MajorFamily>
-
<MajorFamily>
-
<FamilyName>Catalyst 2900 Series</FamilyName>
-
<MinorFamily>
-
<FamilyName>Catalyst 2900 Series Accessories</FamilyName>
-
<ProductNumber>CAB-RPSAC=</ProductNumber>
-
<ProductNumber>CAB-RPSACE=</ProductNumber>
-
<ProductNumber>CAB-RPSY-2218=</ProductNumber>
-
<ProductNumber>CABLEGUARD-C2940=</ProductNumber>
-
<ProductNumber>STK-RACKMOUNT-1RU=</ProductNumber>
-
<ProductNumber>WS-X2948G-RACK=</ProductNumber>
-
<ProductNumber>WS-X2980G-RACK=</ProductNumber>
-
</MinorFamily>
-
<MinorFamily>
-
<FamilyName>Catalyst 2900 Series Software</FamilyName>
-
<ProductNumber>WS-C2980-EMS-LIC=</ProductNumber>
-
</MinorFamily>
-
</MajorFamily>
-
</Root>'
-
-
EXEC sp_xml_preparedocument @idoc OUTPUT, @doc
-
-
-
SELECT *
-
FROM OPENXML (@idoc, '???', 1)
-
WITH
-
-
([MajorFamilyName] nvarchar(255) '???',
-
[MinorFamilyName] nvarchar(255) '???',
-
[ProductNunber] nvarchar(255) '???',
-
)
-
-
EXEC sp_xml_removedocument @idoc
-
5 20676
I've managed to run it on one example - DECLARE @idoc int
-
-
DECLARE @doc varchar (1000)
-
-
SET @doc ='
-
<Root>
-
<MajorFamily>
-
<FamilyName>Training</FamilyName>
-
<MinorFamily>
-
<FamilyName>Cisco Learning Credit</FamilyName>
-
<ProductNumber>TRN-CLC-000</ProductNumber>
-
<ProductNumber>TRN-CLC-001</ProductNumber>
-
<ProductNumber>TRN-CLC-003</ProductNumber>
-
<ProductNumber>TRN-CLC-004</ProductNumber>
-
</MinorFamily>
-
</MajorFamily>
-
</Root>'
-
-
EXEC sp_xml_preparedocument @idoc OUTPUT, @doc
-
print @idoc
-
-
SELECT *
-
FROM OPENXML (@idoc, '/Root/MajorFamily/MinorFamily/ProductNumber', 1)
-
WITH
-
([ImportDate] nvarchar(255) '../../FamilyName',
-
[FileName] nvarchar(255) '../FamilyName',
-
[test] nvarchar(255) '.'
-
)
-
-
EXEC sp_xml_removedocument @idoc
-
But it fails if I add more data
I'm getting this error
Server: Msg 6603, Level 16, State 1, Procedure sp_xml_preparedocument, Line 224
XML parsing error: The following tags were not closed: Root, MajorFamily, MinorFamily, ProductNumber.
It is working after changing data type to varchar(8000) and removing some characters.
However the file I have is 8mb of text and I'm getting this error
The text, ntext, and image data types are invalid for local variables.
Does anyone know how to pass large file into stored procedure? Using T-SQL or VB?
- BEGIN
-
DECLARE @idoc int
-
-
DECLARE @doc nvarchar(max)
-
-
SET @doc ='
-
<Root>
-
<MajorFamily>
-
<FamilyName>CSSP Essential SW</FamilyName>
-
<MinorFamily>
-
<FamilyName>CSSP Ess SW for CallMgr Series Products</FamilyName>
-
<ProductNumber>CON-SESW-SBCSEU</ProductNumber>
-
</MinorFamily>
-
</MajorFamily>
-
<MajorFamily>
-
<FamilyName>Catalyst 2900 Series</FamilyName>
-
<MinorFamily>
-
<FamilyName>Catalyst 2900 Series Accessories</FamilyName>
-
<ProductNumber>CAB-RPSAC=</ProductNumber>
-
<ProductNumber>CAB-RPSACE=</ProductNumber>
-
<ProductNumber>CAB-RPSY-2218=</ProductNumber>
-
<ProductNumber>CABLEGUARD-C2940=</ProductNumber>
-
<ProductNumber>STK-RACKMOUNT-1RU=</ProductNumber>
-
<ProductNumber>WS-X2948G-RACK=</ProductNumber>
-
<ProductNumber>WS-X2980G-RACK=</ProductNumber>
-
</MinorFamily>
-
<MinorFamily>
-
<FamilyName>Catalyst 2900 Series Software</FamilyName>
-
<ProductNumber>WS-C2980-EMS-LIC=</ProductNumber>
-
</MinorFamily>
-
</MajorFamily>
-
</Root>'
-
-
EXEC sp_xml_preparedocument @idoc OUTPUT, @doc
-
-
-
SELECT *
-
FROM OPENXML (@idoc, 'Root/MajorFamily/MinorFamily/ProductNumber', 1)
-
WITH ([MajorFamilyName] nvarchar(255) '../../FamilyName',
-
[MinorFamilyName] nvarchar(255) '../FamilyName',
-
[ProductNunber] nvarchar(255) '../ProductNumber')
-
-
EXEC sp_xml_removedocument @idoc
-
END
try with the above script .. it will work
@Yathirajalb, I guess after 4 years the problem is of no more importance.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: JM |
last post by:
I have a SP set up to take an input param and then fire the following
sp_xml_preparedocument
OPENXML (With a select statement)
sp_xml_removedocument
This works fine with the XML syntax that...
|
by: jrd |
last post by:
The below code is only pulling the outcome_id value, but is pulling
back null for the other fields in the xml string, any ideas on what is
going on?
-- Prepare xml data to be transfered into an...
|
by: Tom |
last post by:
Hi,
I've got problems using ntext data in a stored procedure (SQL-Server
2000):
create procedure testproc
@xmldata ntext
as
declare @Param ntext
|
by: Bostonasian |
last post by:
I've got thousands of XML docs and have to import those to the DB. And
I am having problem with getting some values because of tricky XML
format.
I didn't create this XML format and I don't like...
|
by: Sandy |
last post by:
Hi,
My application writes data into sql server.
Currently it converts data into XML (an in memory XML string) and write
using OPENXML.
I want to know if i write it to a csv file and use BCP,...
|
by: Micke |
last post by:
On a code behing page to an aspx page I want to open a xml file in Excel and
save it as an Excel file. I have following code that is working:
Dim oExcel As New Excel.Application
Dim oBook As...
|
by: figital |
last post by:
I am researching the use of OpenXml for doing mass updates/inserts.
Does anyone know how this procedure works as far as sql injection is
concerned? I've always been taught to use sp's with...
|
by: Shilpa |
last post by:
Hi All,
I want to pass XML and the data in the XML should be stored in the
tables of the database. However, I do not want to use the OpenXML
statement. Please let me know.
Regards, Shilpa
|
by: yingwen |
last post by:
I have a xml similar like this:
<Member ID="123">
<DateBorrowed>11-01-2006</DateBorrowed>
<Book ID="222"
Title="ABC">
<Category> Fiction</Category>
</Book>...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM).
In this month's session, the creator of the excellent VBE...
|
by: MeoLessi9 |
last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: Aftab Ahmad |
last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below.
Dim IE As Object
Set IE =...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: marcoviolo |
last post by:
Dear all,
I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
| |