READTEXT

READTEXT is a SQL Server Transact-SQL command which allows for the reading of large text, ntext, or image type data from a database. This command retrieves the specified chunk or whole data and is primarily used for managing and manipulating large data types. It is important to note that, due to its specific functionality, this command cannot be used with text, ntext, or image columns in a view.

READTEXT { table.column text_ptr [ WITH LOCK ] [ { FIPS_FLAGGER [ OFF ] } ] [ size [ OFFSET start ] ] } [ HOLDLOCK ]]

Example

DECLARE @pointer binary(16)
SELECT @pointer = TEXTPTR(Resume)
FROM Applicants
WHERE ApplicantID = 1
READTEXT Applicants.Resume @pointer 0 50

Output

"An accomplished software engineer specialized in object-or..."

Explanation

In the example, READTEXT is used on the “Resume” column from the “Applicants” table. It reads the text, ntext, or image value - where the ID is 1 - from the offset 0 and for 50 bytes. The output is the first 50 bytes of the “Resume” field of the applicant with an ID of 1.

For in-depth explanations and examples SQL keywords where you write your SQL, install our extension.