This article explains how to expose a local Ollama embedding model over HTTPS for SQL Server 2025, register it as an EXTERNAL MODEL, and generate vectors directly inside the database without an additional Python service layer. Keywords: SQL Server 2025, Ollama, RAG.
The technical specification snapshot is shown below
| Parameter | Description |
|---|---|
| Core topic | Connecting SQL Server 2025 to an Ollama embedding model |
| Language | T-SQL, PowerShell, nginx configuration |
| Protocol | HTTP, HTTPS, REST |
| Runtime components | SQL Server 2025, Ollama, nginx, mkcert |
| Core dependency | nomic-embed-text, External REST Endpoint |
| Star count | mkcert GitHub project; the original article did not provide a specific number |
This solution closes the last-mile gap for in-database RAG implementation
SQL Server 2025 now supports registering large language models as EXTERNAL MODEL objects. That means embedding generation no longer has to depend entirely on an external Python program. For teams building vector search and RAG systems, this can significantly reduce pipeline complexity.
The main challenge is that Ollama exposes an HTTP interface by default, while SQL Server 2025 requires HTTPS for external REST endpoints. The real key is not downloading the model. It is securely wrapping local Ollama as an HTTPS service that SQL Server can trust.
First, verify that the Ollama embedding model is available
# Download and test the embedding model
ollama run nomic-embed-text "Hello"
This step confirms that Ollama is installed correctly on the local machine and that the embedding model can be pulled and started successfully.
Adding HTTPS to Ollama is a prerequisite for connecting it to SQL Server 2025
The full request path has three layers: Ollama provides a local HTTP service on port 11434, nginx handles SSL termination and reverse proxying, and mkcert quickly generates certificates for local use. This combination works well for development machines, internal lab environments, and prototype validation.
Generate a self-signed certificate with mkcert
First, install mkcert and place the executable in an easy-to-access directory. Then use PowerShell to install a local CA and generate a certificate for the machine IP address and localhost.
# Install a local CA so the system can trust the self-signed certificate
.\mkcert.exe -install
# Generate a certificate for the IP, localhost, and loopback addresses
.\mkcert.exe 192.168.1.160 localhost 127.0.0.1 ::1
This step produces a .pem file and a -key.pem file, which nginx will reference directly.
Use nginx to convert Ollama HTTP to HTTPS
nginx has a single job: listen on port 443, load the certificate, and proxy requests to http://localhost:11434. SQL Server then sees a standard HTTPS endpoint, while Ollama itself requires no modification.
http {
server {
listen 443 ssl;
server_name 192.168.1.160; # Replace with your actual IP
ssl_certificate ../certs/your-cert.pem; # Certificate file
ssl_certificate_key ../certs/your-cert-key.pem; # Private key file
location / {
proxy_pass http://localhost:11434; # Reverse proxy to Ollama
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
}
This configuration creates an HTTPS external model endpoint for Ollama that satisfies SQL Server 2025 requirements.
Start, stop, and verify that the HTTPS proxy is working
After you finish the configuration, restart nginx and test both the original HTTP endpoint and the HTTPS proxy endpoint. If the HTTPS request returns a valid result, the prerequisites for external model registration are in place.
# Start nginx in the foreground
nginx
# Stop nginx
nginx -s stop
# Start nginx in the background on Windows
start nginx
These commands manage the nginx process and ensure that the proxy configuration is loaded.
# Test the original Ollama HTTP service
curl http://localhost:11434
# Test the HTTPS service exposed by nginx
curl https://localhost
# Test whether the embeddings endpoint returns vector results correctly
Invoke-RestMethod -Uri https://localhost/api/embeddings `
-Method Post `
-Body '{"model": "nomic-embed-text:latest", "prompt": "博客园最帅的是谁"}' `
-ContentType 'application/json'
This step directly validates the full call chain from HTTPS to the Ollama embeddings API.
SQL Server 2025 can register Ollama directly as an external embedding model
Once the HTTPS endpoint is available, the database side only needs to complete two tasks: enable external REST support and create the EXTERNAL MODEL. After that, vector generation becomes part of the T-SQL workflow.
Enable the external REST endpoint feature first
USE VectorDB;
GO
-- Enable external REST endpoint support
sp_configure 'external rest endpoint enabled', 1;
GO
RECONFIGURE WITH OVERRIDE;
GO
This SQL enables SQL Server 2025 to access external model services.
Then create the EXTERNAL MODEL that points to Ollama
The MODEL parameter must exactly match the model name returned by ollama list. In some environments it appears as nomic-embed-text, while in others it includes the :latest tag. Do not guess the name.
# Check the actual model names available in Ollama
ollama list
This command confirms that the model name in the external model definition matches the actual local deployment.
USE VectorDB;
GO
DROP EXTERNAL MODEL IF EXISTS ollama_nomic_embed_text;
GO
CREATE EXTERNAL MODEL ollama_nomic_embed_text
WITH (
LOCATION = 'https://192.168.1.160:443/api/embed', -- HTTPS endpoint
API_FORMAT = 'Ollama', -- Specify the interface format
MODEL_TYPE = EMBEDDINGS, -- Declare this as an embedding model
MODEL = 'nomic-embed-text:latest' -- Matching Ollama model name
);
GO
-- Verify that the model was created successfully
SELECT * FROM sys.external_models;
GO
After this definition is in place, SQL Server has an embedding model object that you can call directly from queries.
Vector generation can be integrated directly into T-SQL data processing workflows
After the external model is created successfully, you can use AI_GENERATE_EMBEDDINGS for single-text and batch-text scenarios. This is especially straightforward for vector store initialization, incremental ingestion, and offline rebuilds.
-- Generate a vector for a single text input
SELECT AI_GENERATE_EMBEDDINGS(
N'博客园最帅的是谁' USE MODEL ollama_nomic_embed_text
) AS GeneratedEmbedding;
-- Generate vectors for multiple text rows
SELECT TOP 5000
VectorId,
ChunkId,
AI_GENERATE_EMBEDDINGS(
VectorText USE MODEL ollama_nomic_embed_text
) AS Ingredients_Embeddings
FROM dbo.VectorIndex;
This SQL shows how to complete text-to-vector transformation directly inside the database.
This integration path is better suited to internal RAG systems and database-driven applications
Compared with maintaining a standalone Python embedding service, this approach moves model invocation down into the database layer. It fits SQL-driven data pipelines, enterprise internal knowledge bases, and scenarios that require centralized governance.
Keep in mind that this setup is more appropriate for development and testing environments. For production, you should add proper certificates, access controls, observability, and rate limiting at the proxy layer instead of moving an experimental configuration directly into a mission-critical path.

AI Visual Insight: This animated image is primarily used as a page-sharing prompt. It does not convey any technical structure related to SQL Server, Ollama, HTTPS proxying, or vector embeddings, so you can safely ignore it from an engineering perspective.
FAQ structured Q&A
1. Why can’t SQL Server 2025 connect directly to the default Ollama service?
Because Ollama exposes HTTP by default, while SQL Server 2025 requires HTTPS for external REST endpoints. You must use a proxy layer such as nginx to wrap the service with TLS.
2. Why does the MODEL name often cause errors?
Because Ollama tags can differ across machines. For example, one system may show nomic-embed-text, while another shows nomic-embed-text:latest. Before you create the EXTERNAL MODEL, run ollama list to confirm the actual name.
3. Can this approach connect to other model services as well?
Yes. As long as the target service is compatible with an external API format supported by SQL Server, especially services that follow the OpenAI API specification, you can integrate it in a similar way, including Azure OpenAI.
Core summary
This article reconstructs the complete workflow for configuring Ollama as an EXTERNAL MODEL in SQL Server 2025. It covers mkcert certificate generation, nginx HTTPS reverse proxying, external model creation, and vector embedding calls, helping you generate RAG vectors directly inside the database.