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 20703
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_prepared ocument, 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
Dormilich 8,658
Recognized Expert Moderator Expert
@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 microsoft provides in its
documentation ...
<ROOT>
|
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 xml table in sql server
DECLARE @xmlTable varchar(8000)
DECLARE @DocHandle int
select @xmlTable = '<DATA><xmlRow outcome_id="35"
dt_outcome="12/1/2004" patient_regimen_id="21" regimen_id="2"
record_type="existing" /></DATA>'
|
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 this format, OOP snob
did. And I(DBA) have to look after their mess.
I've got XML doc like this :
<customer>
<customer_id>12345</customer_id>
<first_name>Jason</first_name>
|
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, then will it be
faster then OPENXML. (i feel, writing to a csv will create IO operation that
will slow down the process).
| |
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 Excel.Workbook
oBook = oExcel.Workbooks.OpenXML("C:\Test.xml")
Now I want to apply the stylesheet Test.xsl defined in the XML file as:
<?xml-stylesheet type='text/xsl' href='Test.xsl'?>
|
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 parameters...does
using OpenXML open up any holes in that idea?
My thinking is that it would be fine (maybe even better), because the
fields will still be treated as literals.
Alternatively, are there any other suggestions for doing massive
|
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>
<Book ID="333"
Title="ABu">
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |