create_locator

Description

Explicitly creates a locator for a specified LOB then returns the locator.

The locator created by create_locator is valid only for the duration of the transaction containing the query that used create_locator. If no transaction was started, then the locator is valid only until the query containing the create_locator completes execution

Syntax

create_locator (datatype, lob_expression)

Parameters

datatype

is the datatype of the LOB locator. Valid values are:

  • text_locator

  • unitext_locator

  • image_locator

lob_expression

is a LOB value of datatype text, unitext, or image.

Examples

Example 1

Creates a text locator from a simple text expression:

select create_locator(text_locator, convert (text, "abc"))

Example 2

Creates a local variable @v of type text_locator, and then creates a locator using @v as a handle to the LOB stored in the textcol column of my_table.

declare @v text_locator

    select @v = create_locator(text_locator, textcol) from my_table where id=10

Permissions

Any user can execute create_locator.

See also

Commands deallocate locator, truncate lob

Transact-SQL functions locator_literal, locator_valid, return_lob