473,385 Members | 1,523 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

XML issue.

using ms sql 2000

EXEC sp_xml_preparedocument @iTree OUTPUT, @doc

I get an error unless I remove the encoding attribute(<?xml
version="1.0" encoding="utf-8" ?>) from my XML document prior to
running my stored procedure. So I need a way to strip this out via my
C# code that prepares the output.

Thanks.

May 31 '06 #1
6 1754
rhaazy (rh****@gmail.com) writes:
using ms sql 2000

EXEC sp_xml_preparedocument @iTree OUTPUT, @doc

I get an error unless I remove the encoding attribute(<?xml
version="1.0" encoding="utf-8" ?>) from my XML document prior to
running my stored procedure. So I need a way to strip this out via my
C# code that prepares the output.


I'm not really sure what the question is. If you want C# assistence, this
is not the best place.

Then again, OPENXML is perfectly able to handle UTF-8, but you must of
course pass the XML string as UTF-8. Specifically, you need to pass it
as a varchar value.

Try this example (which is posted in Latin-1, and should be handled as
Latin-1):

DECLARE @idoc int
DECLARE @doc varchar(1000)
SET @doc = '<?xml version="1.0" encoding="utf-8" ?>
<ROOT>
<Customers CustomerID="VINET" ContactName=""Räksmörgåis">
</Customers>
</ROOT>'
--Create an internal representation of the XML document.
EXEC sp_xml_preparedocument @idoc OUTPUT, @doc
-- SELECT statement that uses the OPENXML rowset provider.
SELECT *
FROM OPENXML (@idoc, '/ROOT/Customers')
EXEC sp_xml_removedocument @idoc
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
May 31 '06 #2
I can not pass it as a varchar because the max is 8000 i believe, and
my xml file is too large for this. My solution should be as simple as
I have my xml stored into a string prior to it being sent to my stored
procedure, I should just be able to do something like find the int a =
string.indexof( <?xml> > version="1.0" encoding="utf-8" ?>) then find
the length of it then delete it from the string. but i dont know what
to do after finding the index.

Erland Sommarskog wrote:
rhaazy (rh****@gmail.com) writes:
using ms sql 2000

EXEC sp_xml_preparedocument @iTree OUTPUT, @doc

I get an error unless I remove the encoding attribute(<?xml
version="1.0" encoding="utf-8" ?>) from my XML document prior to
running my stored procedure. So I need a way to strip this out via my
C# code that prepares the output.


I'm not really sure what the question is. If you want C# assistence, this
is not the best place.

Then again, OPENXML is perfectly able to handle UTF-8, but you must of
course pass the XML string as UTF-8. Specifically, you need to pass it
as a varchar value.

Try this example (which is posted in Latin-1, and should be handled as
Latin-1):

DECLARE @idoc int
DECLARE @doc varchar(1000)
SET @doc = '<?xml version="1.0" encoding="utf-8" ?>
<ROOT>
<Customers CustomerID="VINET" ContactName=""Räksmörgåis">
</Customers>
</ROOT>'
--Create an internal representation of the XML document.
EXEC sp_xml_preparedocument @idoc OUTPUT, @doc
-- SELECT statement that uses the OPENXML rowset provider.
SELECT *
FROM OPENXML (@idoc, '/ROOT/Customers')
EXEC sp_xml_removedocument @idoc
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx


Jun 1 '06 #3
rhaazy (rh****@gmail.com) writes:
I can not pass it as a varchar because the max is 8000 i believe, and
my xml file is too large for this.
OK, use the text data type then. The important issue is that you should
not pass it as Unicode, that is ntext/nvarchar.
My solution should be as simple as I have my xml stored into a string
prior to it being sent to my stored procedure, I should just be able to
do something like find the int a = string.indexof( <?xml> >
version="1.0" encoding="utf-8" ?>) then find the length of it then
delete it from the string. but i dont know what to do after finding the
index.


As for that question, a C# is a better place.

But as I tried to demonstrate with my repro, there should not be any
need for this.

--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Jun 1 '06 #4

Erland Sommarskog wrote:
rhaazy (rh****@gmail.com) writes: OK, use the text data type then. The important issue is that you should
not pass it as Unicode, that is ntext/nvarchar.

Will this cause any other problems with my XML, are there any
characters that aren't included in the TEXT type that are in NTEXT?

Jun 2 '06 #5
rhaazy (rh****@gmail.com) writes:
OK, use the text data type then. The important issue is that you should
not pass it as Unicode, that is ntext/nvarchar.

Will this cause any other problems with my XML, are there any
characters that aren't included in the TEXT type that are in NTEXT?


Yes and no. Text is 8-bit only, thus normally you have access to one
code page. However, you are passing UTF-8, so you have access to the
same characters as with ntext.

Note, though, that the only context where SQL Server understands UTF-8 is
an XML document which has this encoding. You can store UTF-8 data in
text or varchar columns, but outside XML operations, SQL server will
treat the data as eight bit text, meaning to that sorting will not be
as desired, len() may return an incorrect result etc.
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Jun 2 '06 #6
thanks for all your help, the problem is no more.
Erland Sommarskog wrote:
rhaazy (rh****@gmail.com) writes:
OK, use the text data type then. The important issue is that you should
not pass it as Unicode, that is ntext/nvarchar.

Will this cause any other problems with my XML, are there any
characters that aren't included in the TEXT type that are in NTEXT?


Yes and no. Text is 8-bit only, thus normally you have access to one
code page. However, you are passing UTF-8, so you have access to the
same characters as with ntext.

Note, though, that the only context where SQL Server understands UTF-8 is
an XML document which has this encoding. You can store UTF-8 data in
text or varchar columns, but outside XML operations, SQL server will
treat the data as eight bit text, meaning to that sorting will not be
as desired, len() may return an incorrect result etc.
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx


Jun 2 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Paul Mateer | last post by:
Hi, I have been running some queries against a table in a my database and have noted an odd (at least it seems odd to me) performance issue. The table has approximately 5 million rows and...
7
by: George Hester | last post by:
Please take a look at this google artcle: http://groups.google.com/groups?hl=en&lr=&frame=right&th=55d6f4b50f5f9382&seekm=411f370d%241%40olaf.komtel.net#link9 The op was having trouble with...
2
by: Anthony Cuttitta Jr. | last post by:
We have an application that outputs several different graphs from data downloaded from our AS400. The application has worked without (this) issue for several months now, but just recently, the...
0
by: Kevin Spencer | last post by:
Hi all, I am working on a service that uploads METAR weather information to the National Weather Service FTP site. The service I'm authoring is hosted on a Windows 200 server, and the NWS FTP...
2
by: Ben Rush | last post by:
Hello World, Okay, I have spent the day browsing the newsgroups and reading up on article after article concerning ViewState corruption and so forth, and I have a couple questions. We...
5
by: Robert | last post by:
I have a series of web applications (configured as separate applications) on a server. There is a main application at the root and then several virtual directories that are independant...
0
by: Charles Leonard | last post by:
I am having yet another issue with Windows Server 2003. This time, the web service (a file import web service) appears to run except for one odd message: "ActiveX component can't create object". ...
4
by: Paul | last post by:
Hi, I've been struggling with this today, I'm developing a DotNet2.0 website in C# that needs to call a long running data query. Obviously this is a good candidate for an Asynchronous call, so...
1
by: AlekseyUS | last post by:
Hi, I'm a little stuck, I basically need to copy all the information within a specific file in Temp and append it to a file in another location. I'm not having any problems with smaller size...
13
by: SAL | last post by:
Hello, I'm trying to include a popup in the ItemTemplate of a gridview row. The ItemTemplate for the field contains a textbox and when the user clicks in the textbox I want a popup panel to show...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
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,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.