Can we have array type data in sql server 2008 currently i am using comma seperated value to be treated as array value
Conclusion. As you can see, SQL Server does not include arrays. But we can use table variables, temporary tables or the STRING_SPLIT function. However, the STRING_SPLIT function is new and can be used only on SQL Server 2016 or later versions.
Define arrays as SQL variables. Use the ARRAY_AGG built-in function in a cursor declaration, to assign the rows of a single-column result table to elements of an array. Use the cursor to retrieve the array into an SQL out parameter. Use an array constructor to initialize an array.
To create a column of an array type, the [] symbol is used. The following examples illustrate this: create table contacts ( first_name varchar, last_name varchar, phone_numbers varchar[] ); create table player_scores ( player_number integer, round_scores integer[] );
The LIST data type is a collection type that can store ordered non-NULL elements of the same SQL data type. The LIST data type supports, but does not require, duplicate element values.
SQL Server 2005+ supports table-valued variables:
declare @arr table (col1 int)
insert @arr (col1) values (3), (1), (4)
These are equivalent to arrays.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With