Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 22nd, 2010, 05:51 PM
Authorized User
 
Join Date: Jun 2003
Posts: 54
Thanks: 2
Thanked 0 Times in 0 Posts
Question Replacing Text in NTEXT field

Hello!

I inherited a SS2K application (no chance of upgrade) with a field in a table typed as NVARCHAR(4000) ... storing non-Latin character text.

No I have been tasked with converting the field over to NTEXT so that the users can store more text. I understand my choices for writing the text are UPDATETEXT and WRITETEXT. I need to change a stored procedure so that one NTEXT field in one row has its contents completely replaced. BOL is not clear to me.

Q1: Do I want to use UPDATETEXT or WRITETEXT?

Q2: How do I determine the values of the insert_offset and delete_length when I want to completely replace the contents with new text in one field in one row?

I think I want to use zero for the insert_offset but I am not sure about the delete_length. I have tried 1) a non-zero value, 2) null value, and a 3) zero value. My data is not being replaced.

Here is my code:

Code:
 
DECLARE @ptrval binary(16)
 
BEGIN TRAN
SELECT @ptrval = TEXTPTR(message) FROM LC_Forum_Messages 
WHERE MessageID = @MessageID
 
UPDATETEXT LC_Forum_Messages.Message @ptrval 0 0 @NewMessage
-- @NewMessage is an input parameter to the stored procedure.
 
-- <some error handling left out>
 
COMMIT TRAN
Besides using "0", I have used
  • Null and
  • DATALENGTH(@NewMessage) / 2 -- I understand datalength is in bytes and I need characters. There are 2 bytes per NTEXT character.
For reasons I don't understand, I am not able to replace the old data with the new.

Any ideas of what I am missing?

Any recommendations (short of switching to SS2005) of how to do this better?

Thanks ahead of time for your help!
__________________
--- Tom





Similar Threads
Thread Thread Starter Forum Replies Last Post
Wildcard on nText field rit01 SQL Server 2000 1 March 17th, 2006 12:48 PM
How to Search in nTEXT or TEXT field gaupa SQL Server 2000 1 December 21st, 2004 07:48 AM
Regarding Inserting values to ntext field Hari_Word ADO.NET 1 August 31st, 2004 05:15 PM
Can't pull data from ntext field into recordset. rstelma SQL Server 2000 2 August 26th, 2003 04:50 PM
Can't pull data from ntext field into recordset. rstelma Classic ASP Databases 1 August 26th, 2003 03:21 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.