Reads text, unitext, and image values, starting from a specified offset and reading a specified number of bytes or characters.
readtext [[database.]owner.]table_name.column_name text_pointer offset size [holdlock | noholdlock] [readpast] [using {bytes | chars | characters}] [at isolation { [read uncommitted | 0] | [read committed | 1] | [repeatable read | 2]| [serializable | 3]}]
declare @val varbinary (16) select @val = textptr (copy) from blurbs where au_id = "648-92-1872" readtext blurbs.copy @val 1 5 readpast using chars
The textptr function returns a 16-byte binary string (text pointer) to the text, unitext, or image column in the specified row or to the text, unitext, or image column in the last row returned by the query, if more than one row is returned. Declare a local variable to hold the text pointer, then use the variable with readtext.
The value in the global variable @@textsize, which is the limit on the number of bytes of data to be returned, supersedes the size specified for readtext if it is less than that size. Use set textsize to change the value of @@textsize.
When using bytes as the offset and size, the SAP ASE server may find partial characters at the beginning or end of the text data to be returned. If it does, and character set conversion is on, the server replaces each partial character with a question mark (?) before returning the text to the client.
The SAP ASE server must determine the number of bytes to send to the client in response to a readtext command. When the offset and size are in bytes, determining the number of bytes in the returned text is simple. When the offset and size are in characters, the server must calculate the number of bytes being returned to the client. As a result, performance may be slower when using characters as the offset and size. The using characters option is useful only when the SAP ASE server is using a multibyte character set: it ensures that readtext does not return partial characters.
You cannot use readtext on text, unitext, or image columns in views.
If you attempt to use readtext on text values after changing to a multibyte character set, and you have not run dbcc fix_text, the command fails, and an error message instructs you to run dbcc fix_text on the table.
See also text, image, and unitext Datatypes in Reference Manual: Building Blocks.
ANSI SQL – Compliance level: Transact-SQL extension.
readtext requires select permission on the table.