Use WRITETEXT to replace text, ntext, and image data and UPDATETEXT to modify text, ntext, and image data. UPDATETEXT is more flexible because it changes only a part of a text, ntext, or image column instead of the whole column.
For best performance we recommend that text, ntext, and image data be inserted or updated in chunk sizes that are multiples of 8040 bytes.
If the database recovery model is simple or bulk-logged, text, ntext, and image operations that use WRITETEXT are minimally logged operations when new data is inserted or appended. For more information, see Operations That Can Be Minimally Logged.
Note: |
|---|
|
Minimal logging is not used when existing values are updated.
|
For WRITETEXT to work correctly, the column must already contain a valid text pointer.
If the table does not have in row text, SQL Server saves space by not initializing text columns when explicit or implicit null values are added in text columns with INSERT, and no text pointer can be obtained for such nulls. To initialize text columns to NULL, use the UPDATE statement. If the table has in row text, you do not have to initialize the text column for nulls and you can always get a text pointer.
The ODBC SQLPutData function is faster and uses less dynamic memory than WRITETEXT. This function can insert up to 2 gigabytes of text, ntext, or image data.
In SQL Server, in row text pointers to text, ntext, or image data may exist but may not be valid. For information about the text in row option, see sp_tableoption (Transact-SQL). For information about invalidating text pointers, see sp_invalidate_textptr (Transact-SQL).