ALTER EXTERNAL MODEL (Transact-SQL)

Applies to: SQL Server 2025 (17.x) Preview

Alters an external model object.

Syntax

ALTER EXTERNAL MODEL external_model_object_name
SET
  (   LOCATION = '<prefix>://<path> [ :<port> ] '
    , API_FORMAT = '<OpenAI , Azure OpenAI , etc>'
    , MODEL_TYPE = EMBEDDINGS
    , MODEL = 'text-embedding-ada-002'
    [ , CREDENTIAL = <credential_name> ]
    [ , PARAMETERS = ' { "valid":"JSON" } ' ]
  );

Arguments

external_model_object_name

Specifies the user-defined name for the external model. The name must be unique within the database.

LOCATION

Provides the connectivity protocol and path to the AI model inference endpoint.

API_FORMAT

The API message format for the AI model inference endpoint provider. Accepted values are Azure OpenAI, OpenAI, and Ollama.

MODEL_TYPE

The type of model being accessed from the AI model inference endpoint ___location. Accepted value is EMBEDDINGS.

MODEL

The specific model hosted by the AI provider. For example, text-embedding-ada-002, text-embedding-3-large, or o3-mini.

CREDENTIAL

Indicate which DATABASE SCOPED CREDENTIAL object is used with the AI model inference endpoint.

PARAMETERS

A valid JSON string that contains parameters to be appended to the AI model inference endpoint request message. For example:

'{"Dimensions" : 1536}'

Remarks

Only single external model object can be modified at a time. Concurrent requests to modify the same external model object causes one statement to wait. However, different external model objects can be modified at the same time. This statement can run concurrently with other statements.

Examples

Alter EXTERNAL MODEL and change the MODEL parameter

This example alters the EXTERNAL MODEL named dbo.myAImodel and changes the MODEL parameter.

-- Alter an external model
ALTER EXTERNAL MODEL dbo.myAImodel
SET
(
  MODEL = 'text-embedding-3-large'
);