With SQL Server 2025, Microsoft brings machine learning capabilities into the database engine. This is a significant shift from SQL Server 2022, where any advanced AI or ML had to happen outside the database (using services like Azure ML or external Python/R scripts). The new version introduces features that let you integrate and manage AI models alongside your data, securely and at scale.
Machine Learning & AI Model Management: Smarter Data, Inside the Database

- External AI Model Support (EXTERNAL MODEL) – You can register external AI models in SQL Server 2025, pointing to any REST endpoint for AI services (Azure OpenAI Service, OpenAI's API, Ollama for local models, etc.). Once registered, these models become first-class objects in the database. You can invoke them via T-SQL functions to perform tasks like generating text, analyzing sentiment, or calculating an embedding vector for a piece of data. Importantly, SQL Server can store multiple model versions and includes a built-in retry logic for model calls so that transient failures can be handled gracefully.
- In-Engine AI Orchestration – SQL Server 2025 allows AI workflows to run directly in the database, without needing an external app to orchestrate calls. For example, the database can take a piece of text from a table, send it to an external NLP model for analysis, get the result, and use it in a query, all within a single T-SQL script. This is powerful for scenarios like stored procedures that call AI models. It's also efficient: data doesn't have to leave the database for processing. Microsoft even built features like vector embedding generation and text chunking into T-SQL to support common AI tasks for search and retrieval.
- Vector Embeddings and Native Vector Data Type – A foundational capability for AI in databases is handling vectors (numerical representations of data, often produced by AI models for comparison). SQL Server 2025 introduces a new VECTOR data type to store high-dimensional embeddings (for example, a 768-dimension vector from a language model) efficiently. You can create a vector index using the DiskANN algorithm, a high-performance approximate nearest neighbor index to enable fast similarity searches on these embeddings. Essentially, the database can now measure "semantic similarity," finding records that are alike in meaning, not just exact matches.
- Model Management & Governance – Because models are handled as database objects, SQL Server 2025 provides role-based access control and auditing for model usage. DBAs can control who can invoke a given external model (for example, restrict a costly GPT-4 based model to only the BI team) and track how often it's called. These controls ensure the AI integration is done responsibly. Only authorized users can configure or execute external models, reflecting enterprise governance needs. (We will discuss security in more detail later, but it's worth noting here for model governance.)

Why It Matters
Embedding ML and AI model support into SQL Server means your data and your AI can live in the same place. This reduces latency (no need to export data to an AI service and import results back), and it keeps sensitive data secure on the database server while still leveraging AI insights. It also simplifies application architectures: a single T-SQL query can now do what previously required a separate application or cloud service. This democratizes AI for organizations; database developers or even power users can start using AI on data with T-SQL commands they're comfortable with. By supporting external models from anywhere (cloud or local), SQL Server 2025 is flexible: you can switch model providers without rewriting your queries, which is excellent for testing and evolving AI solutions over time.
Use Cases
- Consider a customer support database where each ticket's text is stored. Using SQL Server 2025, you could register an AI language model for sentiment analysis and run an update query that labels each ticket as Positive, Negative, or Neutral by calling that model for every row. The sentiment model's API endpoint is invoked via EXTERNAL MODEL, and the result is stored in a new column, all done in-place.
- Imagine a marketing analyst can query, "What are the top 5 products mentioned in customer reviews, and what are the common themes?" Even without writing complex SQL, the analyst could use a combination of vector search and an external model. Under the hood, SQL Server might generate embeddings for each review and use a vector similarity search to cluster them by topic, then call an LLM to summarize each cluster. This retrieval-augmented generation (RAG) pattern (combining database retrieval with AI generation) is now feasible inside the database.

To illustrate, imagine a T-SQL procedure:
- A pre-built embedding model (registered as an external model) is used to vectorize all product review texts and store these vectors in a VECTOR column.
- Performs a similarity search on these vectors to find reviews related to a user's query or group similar feedback.
- Calls an external large language model to summarize each group of similar reviews into a theme description.
- Returns the themes and example reviews.
All steps can be done within SQL Server. A process that once required exporting data to a separate ML pipeline is now streamlined, enabling real-time or on-demand AI insights directly where the data resides.
In-Database Machine Learning
External Models in T-SQL: Register and call AI models (OpenAI, Azure, local) as if they were built-in functions.
Vectors & Semantic Search: Store embeddings and use DiskANN indexing for fast similarity lookup of data by meaning.

Conclusion
SQL Server 2025 is bringing AI directly to your data. Instead of shipping data off to external services, you can now run models and handle vector searches using standard T-SQL. It’s faster, more secure, and way easier to manage than the old way of doing things. If you know SQL, you’re now ready to run AI at scale.
Shop our SQL Server 2025 Products
![]() |
Details
|

