You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/sql-server/what-s-new-in-sql-server-2025.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -50,7 +50,7 @@ For the best experience with [!INCLUDE [sql-server-2025](../includes/sssql25-md.
50
50
51
51
### Web edition
52
52
53
-
- Web edition is discontinued.
53
+
- Web edition is discontinued. For more information, see the [Product Changes](https://techcommunity.microsoft.com/blog/SQLServer/sql-server-2025-is-now-generally-available/4470570) section in the SQL Server 2025 GA blog post.
Copy file name to clipboardExpand all lines: docs/t-sql/functions/ai-generate-embeddings-transact-sql.md
+51-20Lines changed: 51 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ description: The AI_GENERATE_EMBEDDINGS function creates vector arrays for data.
4
4
author: jettermctedder
5
5
ms.author: bspendolini
6
6
ms.reviewer: randolphwest
7
-
ms.date: 11/18/2025
7
+
ms.date: 11/17/2025
8
8
ms.service: sql
9
9
ms.subservice: t-sql
10
10
ms.topic: reference
@@ -42,13 +42,13 @@ An [expression](../language-elements/expressions-transact-sql.md) of any charact
42
42
43
43
#### *model_identifier*
44
44
45
-
The name of an [EXTERNAL MODEL](../statements/create-external-model-transact-sql.md) defined as an `EMBEDDING` type that is used to create the embeddings vector array.
45
+
The name of an [external model](../statements/create-external-model-transact-sql.md) defined as an `EMBEDDINGS` type that is used to create the embeddings vector array.
46
46
47
47
For more information, see [CREATE EXTERNAL MODEL](../statements/create-external-model-transact-sql.md).
48
48
49
49
#### *optional_json_request_body_parameters*
50
50
51
-
A valid JSON formatted list of additional parameters. These parameters are appended to the REST request message body before being sent to the `EXTERNAL MODEL`'s endpoint location. These parameters are depenantant on what the `EXTERNAL MODEL`'s endpoint supports and accepts.
51
+
A valid JSON formatted list of additional parameters. These parameters are appended to the REST request message body before being sent to the external model's endpoint location. These parameters depend on what the external model's endpoint supports and accepts.
52
52
53
53
## Return types
54
54
@@ -83,17 +83,22 @@ The format of the returned JSON is as follows:
83
83
84
84
### Prerequisites
85
85
86
-
There are two prerequisites you must meet to use `AI_GENERATE_EMBEDDINGS`:
86
+
You must meet the following prerequisites to use `AI_GENERATE_EMBEDDINGS`:
87
87
88
-
-`sp_invoke_external_endpoint`must be enabled in the database using [sp_configure](../../relational-databases/system-stored-procedures/sp-invoke-external-rest-endpoint-transact-sql.md?tabs=request-headers#permissions).
88
+
-Enable `sp_invoke_external_endpoint`on the database, with the following command:
89
89
90
-
- an [EXTERNAL MODEL](../statements/create-external-model-transact-sql.md) of the `EMBEDDINGS` type, accessible via the correct grants, roles, and/or permissions.
- Create an [external model](../statements/create-external-model-transact-sql.md) of the `EMBEDDINGS` type, accessible via the correct grants, roles, and/or permissions.
91
96
92
97
### Optional parameters
93
98
94
99
The parameter `optional_json_request_body_parameters` in `AI_GENERATE_EMBEDDINGS` is used when an endpoint parameter needs to be added to the body of the embeddings request message. Adding an optional parameter overrides the value at runtime if that parameter is defined in the model definition.
95
100
96
-
For example, if the [EXTERNAL MODEL](../statements/create-external-model-transact-sql.md) contains the parameter for `dimensions` set to 1536, by passing that parameter in the `optional_json_request_body_parameters` at runtime with a new value as seen here: `json_object('dimensions':755)`, the `dimensions` parameter on the model is overridden.
101
+
For example, if the [external model](../statements/create-external-model-transact-sql.md) contains the parameter for `dimensions` set to 1536, by passing that parameter in the `optional_json_request_body_parameters` at runtime with a new value as seen here: `json_object("dimensions":755)`, the `dimensions` parameter on the model is overridden.
97
102
98
103
The value passed into `optional_json_request_body_parameters` must be valid JSON.
99
104
@@ -103,13 +108,13 @@ For more information on creating embedding endpoints, review the process for [Az
103
108
104
109
### Extended Events (XEvent)
105
110
106
-
`AI_GENERATE_EMBEDDINGS` has an extended event (``ai_generate_embeddings_summary``) that can be enabled for troubleshooting. It contains information about the REST request and response such as status code, any errors it encountered, the model name used, and token counts used by the embedding endpoint. The extended event ``external_rest_endpoint_summary`` contains additional information that can be for troubleshooting and debugging REST requests.
111
+
`AI_GENERATE_EMBEDDINGS` has an extended event (`ai_generate_embeddings_summary`) that can be enabled for troubleshooting. It contains information about the REST request and response such as status code, any errors it encountered, and the model name used. The extended event `external_rest_endpoint_summary` contains additional information that can be for troubleshooting and debugging REST requests.
107
112
108
113
## Examples
109
114
110
115
### A. Create embeddings with a SELECT statement
111
116
112
-
The following example shows how to use the `AI_GENERATE_EMBEDDINGS` function with a select statement which returns vector array results.
117
+
The following example shows how to use the `AI_GENERATE_EMBEDDINGS` function with a select statement that returns results in a JSON array.
113
118
114
119
```sql
115
120
SELECT id,
@@ -119,15 +124,15 @@ FROM myTable;
119
124
120
125
### B. Create embeddings with a SELECT statement using AI_GENERATE_CHUNKS
121
126
122
-
The following example shows how to use the `AI_GENERATE_EMBEDDINGS` function with the `AI_GENERATE_CHUNKS` function to pass text broken up in specified chunk sizes with a select statement which returns vector array results.
127
+
The following example shows how to use the `AI_GENERATE_EMBEDDINGS` function with the [AI_GENERATE_CHUNKS](ai-generate-chunks-transact-sql.md) function to pass text broken up in specified chunk sizes with a select statement that returns vector array results.
123
128
124
129
```sql
125
130
SELECT id,
126
131
title,
127
132
large_text,
128
-
AI_GENERATE_EMBEDDINGS(c.chunk_text USE MODEL MyAzureOpenAiModel)
133
+
AI_GENERATE_EMBEDDINGS(c.chunk_text USE MODEL MyAzureOpenAIModel)
@@ -136,7 +141,7 @@ The following example shows how to use the `AI_GENERATE_EMBEDDINGS` function wit
136
141
137
142
```sql
138
143
UPDATE t
139
-
SET myEmbeddings = AI_GENERATE_EMBEDDINGS(t.text USE MODEL MyAzureOpenAiModel)
144
+
SET myEmbeddings = AI_GENERATE_EMBEDDINGS(t.text USE MODEL MyAzureOpenAIModel)
140
145
FROM myTable AS t;
141
146
```
142
147
@@ -146,16 +151,42 @@ The following example shows how to use the `AI_GENERATE_EMBEDDINGS` function wit
146
151
147
152
```sql
148
153
SELECT id,
149
-
AI_GENERATE_EMBEDDINGS(large_text USE MODEL MyAzureOpenAIModel PARAMETERS '{"dimensions" : 768 }')
154
+
AI_GENERATE_EMBEDDINGS(large_text USE MODEL MyAzureOpenAIModel PARAMETERS TRY_CONVERT (JSON, N'{"dimensions":768}'))
150
155
FROM myTable;
151
156
```
152
157
153
-
### E. A full example with chunking, AI_GENERATE_EMBEDDINGS, and model creation
158
+
### E. Retry embeddings generation with `retry_count` PARAMETERS option
159
+
160
+
If the embeddings call encounters HTTP status codes indicating temporary issues, you can configure the request to automatically retry.
161
+
162
+
To specify the number of retries, add the following JSON to the `PARAMETERS` option. This value should be a positive integer between zero (`0`) and ten (`10`) inclusive, and can't be `NULL`.
163
+
164
+
> [!NOTE]
165
+
> If a `retry_count` value is specified in the `AI_GENERATE_EMBEDDINGS` query, it overrides the `retry_count` (if defined) in the external model's configuration.
166
+
167
+
```sql
168
+
SELECT id,
169
+
AI_GENERATE_EMBEDDINGS(large_text USE MODEL MyAzureOpenAIModel PARAMETERS TRY_CONVERT (JSON, N'{"retry_count":10}'))
170
+
FROM myTable;
171
+
```
172
+
173
+
### F. A full example with chunking, AI_GENERATE_EMBEDDINGS, and model creation
174
+
175
+
The following example demonstrates an end-to-end process for making your data AI-ready:
176
+
177
+
1. Use [CREATE EXTERNAL MODEL](../statements/create-external-model-transact-sql.md) to register and make your embedding model accessible.
178
+
179
+
1. Split the dataset into smaller chunks with [AI_GENERATE_CHUNKS](ai-generate-chunks-transact-sql.md), so the data fits within the model's context window and improves retrieval accuracy.
180
+
181
+
1. Generate embeddings using `AI_GENERATE_EMBEDDINGS`.
182
+
183
+
1. Insert the results into a table with a [vector data type](../data-types/vector-data-type.md).
154
184
155
-
This example is a full flow from creating the [CREATE EXTERNAL MODEL](../statements/create-external-model-transact-sql.md), using `AI_GENERATE_EMBEDDINGS`, and using [AI_GENERATE_CHUNKS](ai-generate-chunks-transact-sql.md) to insert the results into a table with a **vector** data type. Remember to replace `<password>` with a valid password.
185
+
> [!NOTE]
186
+
> Replace `<password>` with a valid password.
156
187
157
188
```sql
158
-
--Turn external REST endpoint invocation ON in the database
189
+
--Enable the external REST endpoint invocation on the database server
PRODUCT ( [ ALL ] expression) OVER ( [ PARTITION BY clause ] ORDER BY clause)
49
+
PRODUCT ( [ ALL ] expression) OVER ( [ partition_by_clause ] [ order_by_clause ] )
50
50
```
51
51
52
52
## Arguments
@@ -63,13 +63,13 @@ Specifies that PRODUCT returns the PRODUCT of unique values.
63
63
64
64
A constant, column, or function, and any combination of arithmetic, bitwise, and string operators. *expression* is an expression of the exact numeric or approximate numeric data type category, except for the **bit** data type. Aggregate functions and subqueries aren't permitted. For more information, see [Expressions](../language-elements/expressions-transact-sql.md).
65
65
66
-
#### OVER ( [PARTITION BY clause ] ORDER BY *clause* )
66
+
#### OVER ( [*partition_by_clause*][*order_by_clause*] )
67
67
68
68
Determines the partitioning and ordering of a rowset before the function is applied.
69
69
70
-
`PARTITION BY` clause divides the result set produced by the FROM clause into partitions to which the function is applied. If not specified, the function treats all rows of the query result set as a single group.
70
+
*partition_by_clause*divides the result set produced by the `FROM` clause into partitions to which the function is applied. If not specified, the function treats all rows of the query result set as a single group.
71
71
72
-
`ORDER BY` clause determines the logical order in which the operation is performed. Required. For more information, see [SELECT - OVER clause](../queries/select-over-clause-transact-sql.md).
72
+
*order_by_clause*determines the logical order in which the operation is performed. For more information, see [SELECT - OVER clause](../queries/select-over-clause-transact-sql.md).
0 commit comments