Reads text, ntext, or image values from a text, ntext, or image column, starting from a specified offset and reading the specified number of bytes.
READTEXT {table.column text_ptr offset size} [HOLDLOCK]
Use the TEXTPTR function to obtain a valid text_ptr value. TEXTPTR returns a pointer to the text, ntext, or image column in the specified row or to the text, ntext, or image column in the last row returned by the query if more than one row is returned. Because TEXTPTR returns a 16-byte binary string, it is best to declare a local variable to hold the text pointer and then use the variable with READTEXT. For more information about declaring a local variable, see DECLARE @local_variable.
The value of the @@TEXTSIZE function supersedes the size specified for READTEXT if it is less than the specified size for READTEXT. The @@TEXTSIZE function is the limit on the number of bytes of data to be returned set by the SET TEXTSIZE statement. For more information about how to set the session setting for TEXTSIZE, see SET TEXTSIZE.
READTEXT permissions default to users with SELECT permissions on the specified table. Permissions are transferable when SELECT permissions are transferred.
This example reads the second through twenty-sixth characters of the pr_info column in the pub_info table.
USE pubs
GO
DECLARE @ptrval varbinary(16)
SELECT @ptrval = TEXTPTR(pr_info)
FROM pub_info pr INNER JOIN publishers p
ON pr.pub_id = p.pub_id
AND p.pub_name = 'New Moon Books'
READTEXT pub_info.pr_info @ptrval 1 25
GO
@@TEXTSIZE | WRITETEXT |
UPDATETEXT |