UPDATEEXT:
This SQL command is used to update an existing text, ntext, or image
field. Use UPDATETEXT to change only a portion of a text, ntext, or image column in place.
Use WRITETEXT to update and replace an entire text, ntext, or image field.
Syntax
UPDATETEXT {table_name.dest_column_name dest_text_ptr}
{
NULL
| insert_offset
}
{
NULL
| delete_length
}
[WITH LOG]
[
inserted_data
| [{table_name.src_column_name src_text_ptr}
]
where
table_name.dest_column_name:Is the name of the table and text, ntext, or image column to
be updated.
dest_text_ptr :Is a text pointer value (returned by the TEXTPTR function) that points to the text, ntext, or image data to be updated.dest_text_ptr must be binary(16).
insert_offset :Is the zero-based starting position for the update. For text or image columns, insert_offset is the number of bytes to skip from the start of the existing column before inserting new data. A value of 0 inserts the new data at the beginning of the existing data. A value of NULL appends the new data to the existing data value.
delete_length :Is the length of data to delete from the existing text, ntext, or image column, starting at the insert_offset position. The delete_length value is specified in bytes for text and image columns and in characters for ntext columns. Each ntext character uses 2 bytes. A value of 0 deletes no data. A value of NULL deletes all data from the insert_offset position to the end of the existing text or image column.
WITH LOG:Specifies that the inserted text, ntext, or image data is logged. This option allows recovery, but it can quickly increase the size of the transaction log.
inserted_data:Is the data to be inserted into the existing text, ntext, or image column at the insert_offset location. This is a single char, nchar, varchar, nvarchar, binary, varbinary, text, ntext, or image value. inserted_data can be a literal or a variable.
table_name.src_column_name:Is the name of the table and text, ntext, or image column used as the source of the inserted data. Table names and column names must conform to the rules for identifiers.
src_text_ptr :Is a text pointer value (returned by the TEXTPTR function) that points to a text, ntext, or image column used as the source of the inserted data.
EXAMPLE:
UPDATETEXT report_table.report @ptrval NULL 0 @com
This command will update the data in table report_table, field report. The
NULL tell SQL server to append the data and the 0 makes sure that none of the data is
deleted. @com is the variable that stores the data from the source. The variable in this
case was VARCHAR(255)