Forum Discussion

sebflaesch67's avatar
sebflaesch67
Copper Contributor
Jan 07, 2026

SQL Server 2025 VECTOR functions accepting JSON array strings

Hello!

Playing with new VECTOR type and functions, I can read following https://learn.microsoft.com/en-us/sql/t-sql/functions/vector-distance-transact-sql?view=sql-server-ver17 for vector parameters:

An expression that evaluates to vector data type.

To me this means that any expression (including character strings as JSON-arrays) can be used as parameter.

Since INSERT statement accepts to convert a JSON-array string to a VECTOR, I would expect that these function also accept this conversion.

However, it appears that we are forced to cast the JSON-array to VECTOR.

Any chance to improve this?

Here some T-SQL example:

declare v1 as VECTOR(3) = '[-1,1,0]'
declare S1 as VARCHAR(50) = '[-1,1,0]'

drop table tab1;
create table tab1 (pkey int not null primary key, emb vector(3));
insert into tab1 values ( 101, v1 );
insert into tab1 values ( 102, S1 );

select * from tab1 order by pkey;

select vector_distance('cosine',emb,@v1) from tab1;

select vector_distance('cosine',emb,@s1) from tab1;          -- fails

 

Seb

No RepliesBe the first to reply

Resources