ARRAY_SET Function

Creates a new array by copying an existing array and replacing one of the elements. The existing array is not modified.

Syntax

ARRAY_SET(array, element-index, value)

Parameters

Return Value

The new array, with the element at index element-index replaced with value. If the index is out of range, then an error is raised.

Example

DECLARE @a = ARRAY(111, 222, 333);
DECLARE @b = ARRAY_SET(@a, 2, 999);
PRINT @a; -- "[111, 222, 333]"
PRINT @b; -- "[111, 222, 999]"

See Also