Returns a pointer to the first page of a text, image, or unitext column.
textptr(column_name)
is the name of a text column.
Uses the textptr function to locate the text column, copy, associated with au_id 486-29-1786 in the author’s blurbs table. The text pointer is placed in local variable @val and supplied as a parameter to the readtext command, which returns 5 bytes, starting at the second byte (offset of 1):
declare @val binary(16) select @val = textptr(copy) from blurbs where au_id = "486-29-1786" readtext blurbs.copy @val 1 5
Selects the title_id column and the 16-byte text pointer of the copy column from the blurbs table:
select au_id, textptr(copy) from blurbs
textptr, a text and image function, returns the text pointer value, a 16-byte varbinary value.
The textptr value returned for an in-row LOB column residing in a data-only-locking data row that is row-forwarded remains unchanged and valid after the forwarding.
If a text, unitext, or image column has not been initialized by a non-null insert or by any update statement, textptr returns a NULL pointer. Use textvalid to check whether a text pointer exists. You cannot use writetext or readtext without a valid text pointer.
Trailing f
in varbinary values
are truncated when they are stored in tables. If storing text pointer
values in a table, use binary as the column’s
datatype.
ANSI SQL – Compliance level: Transact-SQL extension.
Any user can execute textptr.
Datatypes text, image, and unitext datatypes
Documentation Transact-SQL Users Guide
Function textvalid