| Author |
Topic |
|
majkinetor
Yak Posting Veteran
55 Posts |
Posted - 2006-03-14 : 08:32:09
|
I have xml that I have to supplay to xml_preparedocument procedure and before that I need to load all text into variable. So far I was unable to do this because of several reasons, the most important to be that you can't use ntext variables in SQL Server 2000.I used this code to get xml text to ntext table field (MSDN: Brief Tutorial on Text, Ntext, and Image) create table ##t (n ntext)insert ##t values('SOME TEXT HERE')EXEC readNtextFromfile 'c:\IE-PDP.xml', '##t','n', ''SELECT n FROM ##tDROP TABLE ##t
I see the correct text on output but I can't do anything to transmit this data to sp_xml_preparedocument becuase it expects it to be in variable and you can't use ntext variables localy.I tried this but with no success: PROCEDURE dbo.test( @DOC NTEXT = NULL OUTPUT)ASDECLARE @hDoc INT create table ##t (n ntext)insert ##t values('SOME TEXT HERE')EXEC readNtextFromfile 'c:\IE-PDP.xml', '##t','n', ''SET @DOC = (SELECT n FROM ##t)DROP TABLE ##tEXEC sp_xml_preparedocument @hDoc OUTPUT, @DOCRETURN
but I got complaints for line SET @DOC = (SELECT n FROM ##t). I tried to fool SQL Server this way to let me write to NTEXT variable (btw, how can I set NTEXT OUTPUT this way - documentation said that it can be used, so I don't know what is the problem with this code)What should I do ?The only way for now is to call procedure that will handle my xml with xml text parameter instead of file parameter from ADO.NET, but I don't want to use this method if I can do it in plain T-SQL.Thx in advance. |
|
|
majkinetor
Yak Posting Veteran
55 Posts |
Posted - 2006-03-15 : 08:26:06
|
| hard question or you have some problems understanding the isue ? |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-03-15 : 08:34:49
|
| >>SET @DOC = (SELECT n FROM ##t)You will get error if the subquery returns more than one valueIf you want to execute that sp against each value of the column, then you should use Cursor or While loopMadhivananFailing to plan is Planning to fail |
 |
|
|
majkinetor
Yak Posting Veteran
55 Posts |
Posted - 2006-03-16 : 02:50:48
|
| I have only one value !readNtextFromfile will crate table with only 1 field, containing all the text from the file. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-03-16 : 03:19:17
|
| >>but I got complaints for line SET @DOC = (SELECT n FROM ##t).What is the error you got?MadhivananFailing to plan is Planning to fail |
 |
|
|
majkinetor
Yak Posting Veteran
55 Posts |
Posted - 2006-03-16 : 08:04:57
|
| Message: The text, ntext, and image data types are invalid in this subquery or aggregate expression.Message: The assignment operator operation cannot take a ntext data type as an argument. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-03-16 : 08:08:12
|
| Why did you declare n as nText?Cant you use Varchar datatype?When you say "Some text here", what type of text do you mean?MadhivananFailing to plan is Planning to fail |
 |
|
|
majkinetor
Yak Posting Veteran
55 Posts |
Posted - 2006-03-17 : 06:46:19
|
| n must be nText because it should recevie whole XML which is larger then 8000 chars available for nvarcharI use Some text here just to initiate this field. |
 |
|
|
RyanRandall
Master Smack Fu Yak Hacker
1074 Posts |
|
|
majkinetor
Yak Posting Veteran
55 Posts |
Posted - 2006-03-20 : 09:20:53
|
| Thenk you very muchI changed my storeproc to receive just one "XML row" at the time, but this article can't harm. |
 |
|
|
|