The evolution of AI is booming and brings many new possibilities to enhance efficiency and convenience with many different use cases. While AI chatbots have had an almost revolutionary influence in recent years, we are now entering the next phase of this evolution with context-aware AI assistants and autonomous AI agents that will have even more impact.

Providers of modern and future-oriented platforms and applications seem to be aware of this development and are integrating AI in a targeted manner to increase efficiency and improve the user experience.

With SQL Server 2025 being the most developer-oriented release in over a decade, Microsoft is clearly targeting the AI evolution making it easier than ever to integrate AI with your data.

In this article I will introduce you in two of the latest AI oriented features which are now available in SQL-Server 2025 preview and I will show you an example how you can interact with an external AI-model programmatically.

sp_invoke_external_rest_endpoint:

While the stored procedure sp_invoke_external_rest_endpoint was already available in Azure SQL Database and Managed Instance it’s now also available in  SQL-Server 2025 Preview and allows you to communicate with external REST services from On-Premise.

This is significant in terms of AI because AI-models which are hosted on Cloud Platforms or on Premise (for example with Ollama) are usually REST compatible. This stored procedure allows you so to interact with an external AI model directly and programmatically through T-SQL.

You can find more information about the stored procedure and the specific parameters on the following Link from Microsoft: https://learn.microsoft.com/en-us/sql/relational-databases/system-stored-procedures/sp-invoke-external-rest-endpoint-transact-sql?view=sql-server-ver17&tabs=request-headers

JSON Datatype:

In the previous version of SQL-Server JSON Data was stored in the varchar and nvarchar datatypes. With SQL-Server 2025 you can now store JSON data in a JSON datatype. The JSON datatype which is also available in Azure SQL Database and Azure SQL Managed Instance brings multiple advantages over working with JSON Data in nvarchar and varchar datatypes.

As the new JSON Datatype is compatible with all JSON functions no code change is necessary while benefiting from the following advantages:

  • reads are faster because with the JSON datatype your JSON data is already parsed
  • you can update also individual values without accessing the whole JSON data
  • the JSON datatype is optimized for compression which makes the storage more efficient

In terms of AI this is significant because external AI-models are usually transferring data in the JSON format. With the new JSON datatype you can handle this data efficiently.

To get more detailed information’s about handling JSON data with T-SQL and about the new JSON datatype, you can access the following Link from Microsoft: https://learn.microsoft.com/en-us/sql/relational-databases/json/json-data-sql-server?view=sql-server-ver17

Hands On – Generating Product Descriptions using AI:

Enough theory for now! let’s get practical. For demonstration purposes, I’ve prepared a sample shop database for a clothing reseller running on SQL-Server 2025.

The database has some few tables which are containing product information’s:

With the following query you can see that we have 3000 products with different categories from different brands etc.

select p.product_id, p.product_name, p.currency, p.price, c.category_name, b.brand_name, co.color_name, g.gender, s.season 
from dbo.products p 
inner join dbo.category c on p.category_id = c.category_id 
inner join dbo.brand b on p.brand_id = b.brand_id 
inner join dbo.color co on p.color_id = co.color_id 
inner join dbo.gender g on p.gender_id = g.gender_id
inner join dbo.season s on p.season_id = s.season_id

What we don’t have is a product description for attracting potential buyers. This is something we will do now using AI. Therefore I need an AI model which I can integrate with my product data. I deploy this model in Azure.

Deploy an AI Model in Azure:

In the Azure Portal I’m looking therefore for Azure AI Foundry.

Then under AI Foundry I create a new resource of Azure OpenAI:

The deployment is pretty much straight forward and after the deployment is finished I access my newly created resource:

In my new Azure OpenAI resource I’m accessing now the Azure AI Foundry portal for deploying a new AI-model:

In the AI Foundry Portal I’m looking under the Model catalog for chat completion models and I select the gpt-4o model which is the “allrounder” AI-model for chat completion tasks from OpenAI(It’s in fact currently the model you are using with ChatGPT by default if you don’t choose anything else specifically):

After clicking on the gpt-4o model, I clik on “Use this model” and finally on “deploy” for deploying the model:

As far as I deployed the model successfully I’m able to find it in the Azure AI Foundry Portal under “Deployments”:

After clicking on the newly deployed model I can also find my https URL and API key for accessing the model:

Interacting with the AI Model using T-SQL:

As the model is now successfully deployed we are ready to interact with it using T-SQL. Therefore I wrote a small stored procedure around the stored procedure sp_invoke_external_rest_endpoint which is doing the following stuff:

It takes the Product ID, API Key, API Endpoint URL and the desired description language as input parameters:

It selects necessary product data for the provided Product ID from the database and stores it as a single string:

It generates a prompt for the chat completion API and dynamically interpolates the selected product data into that prompt:

Finally it invokes the external AI model using the stored procedure sp_invoke_external_rest_endpoint with the generated prompt:

With the code below I’m then executing the stored procedure above for a specific product in my database and I’m extracting the product description from the AI models JSON response:

As a random example I have this swim shorts in the color magenta in my Shop database with the product ID 2354:

I’m now able to generate a product description using the gpt-4o model hosted in Azure for this specific product:

You can see here the full product description which was returned by the gpt-4o model:

Make a bold splash this summer with these vibrant magenta swim shorts from River Island. Designed for the modern man, they combine style and comfort, ensuring you stand out at the beach or poolside. Don’t just swim—make a statement. Grab yours now and own the summer vibe!

The description is pretty good isn’t it? If magenta suited me, I would definitely buy one 😉

The GPT-4 model is also quite a language expert. For example, you can even generate your product descriptions in Chinese.

In case that I have Chinese speaking blog readers or if someone wants to translate it, here is again the full description:

亮眼的紫红色泳裤,让您在夏日海滩上成为焦点!River Island精心设计,兼具时尚与舒适,完美贴合男性身形。无论是游泳还是晒日光浴,这款泳裤都是您的理想选择。立即下单,开启您的夏日魅力之旅!

If you want to test it by your own you can find the whole code and a backup of the ShopAI database on GitHub: https://github.com/HocineMechara/SQL2025-AI-Product-Description-Blog

Of course, this is just a simple example. You can do much more. For instance, you could provide additional context to the chat completion model, such as the user’s recent orders or behavioral data, to generate personalized product descriptions tailored to individual customers.

Feel free to share your thoughts in the comments, and stay tuned for upcoming posts from my colleagues and me. 😉