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 20685
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: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |