March 10, 2004 at 6:03 am
Guys,
can anyone help, I have an ntext field in a content manager database table the field is called Content the value in the field looks something like
<Content_sch_standard xmlns="uuid:81689BE8-11A4-417A-AB00-C0B2204C5875">
<content><html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<!--Start of Page Content-->
<h1>Richards Doc</h1>
<p>test contentsaghdfkghsfgd</p>
<p>bncbgm</p>
<!--End of Page Content-->
</body>
</html>
</content>
</Content_sch_standard>
What i need to do is some string manipulation with a sql query that will replace the text
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
with nothing thus effectively deleting it and the same with text
</body>
</html>
cannot use replace because its an ntext field. Any suggestions??
Thanks in advance
regards
March 11, 2004 at 6:59 am
Hi Ismail,
Would this work:
select top 1 replace(cast(your_ntext_field as nvarchar(4000)),'Searchval','Replaceval') from yourtablename
If you expect up to 8000 bytes and no Unicode characters, you could use varchar(8000) instead of nvarchar(4000).
-Mike
March 11, 2004 at 8:14 am
I did some basic research and found the following SQL commands. Look at READTEXT, TEXTPRT and UPDATETEXT. From what I read this seems to allows you to read chunks of the ntext string then write, update or delete chunks from the ntext field.
The one item of interest is that the READTEXT and the UPDATETEXT use binary variables. This means that you will probably need to convert the binary variables to varchar variables, update the values you wish to update then convert the varchar variables back to binary.
If I am correct then you will need to use a stored procedure with a cursor to process each of the ntext columns of each of the rows of your table.
I hope this helps.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply