In the data we often encounter ntext large text type, this type if and nvarchar type addition can have problems, so there is a way to solve this problem.
SQL functions used:
TEXTPTR: Returns the value of the text pointer to the textual, ntext, or image data to be updated.
UPDATETEXT: Change part of text, ntext, or image column in the appropriate location
WRITETEXT: To update and replace the entire text, ntext, or image fields
Example:
CREATE TABLE [dbo]. [AA] (
[ID] [int] NULL,
[Content] [ntext] Null
)
Insert AA values (1, ' AA ');
Insert AA values (2, ' BB ');
DECLARE @ptr Binary (16)
DECLARE @val nvarchar (100)
SET @val = ' sssss '
SELECT @ptr = TEXTPTR (content) from AA WHERE id=2
UPDATETEXT aa.content @ptr NULL 0 @val the end of the content of-------------id=2 plus @val
UPDATETEXT aa.content @ptr 0 0 @val-------------id=2 The content of the head plus @val
function UpdateText Parse parameter: first parameter: The ntext Type field to update in the table. Second: A pointer to this field. Third: the inserted position (a value of 0 means that new data is inserted at the beginning of the existing location.) A value of NULL appends the new data to the existing data value. )。 IV: The BYTE to delete (a value of 0 means that data is not deleted.) A value of NULL deletes any data from the existing text or image column starting at the insert_offset position to the end. )。 V: the string to accumulate.
The Text Type field value in SQL Server appends a string method to the database