ARRAY_INSERT
Function
Creates a new array by copying an existing array and inserting one or more elements. The existing array is not modified.
Syntax
ARRAY_INSERT(array, element-index, value1, [value2], ...)
Parameters
- array: blob
The existing array to copy. - element-index: integer
Zero-based index into the array, specifying where to insert the new elements. If element-index equals the length of the array (i.e. one index past the last element) then the value is appended to the array. - value1, value2, ...: scalar
The values to insert at the specified location.
Return Value
The new array, with the new values inserted at index element-index.Example
DECLARE @a = ARRAY(111, 222, 333);
DECLARE @b = ARRAY_INSERT(@a, 2, 999);
PRINT @a; -- "[111, 222, 333]"
PRINT @b; -- "[111, 222, 999, 333]"