Get started with the langchain_sqlserver
library with the following tutorials. All the tutorials works with Azure SQL or SQL Server 2025.
Note
SQL Server 2025 is available as Community Technology Preview (CTP) 1.0. To get more info on how to get the CTP, take a look here: Announcing Microsoft SQL Server 2025: Enterprise AI-ready database from ground to cloud
Note
In Azure SQL, Vector Functions are in Public Preview. Learn the details about vectors in Azure SQL here: https://aka.ms/azure-sql-vector-public-preview
If you're just getting started with LangChain, take a look at this article with the related sample: LangChain Integration for Vector Support for SQL-based AI applications
If you already have some familiarity with LangChain, and you are looking for samples that helps you to get started using LangChain with SQL Serve or Azure SQL, you can jump directly to the samples below.
Make sure the create an .env
using .env.example
as a template.
Samples on how to use the langchain_sqlserver
library with SQL Server or Azure SQL as a vector store are:
test-1.py
: Basic sample to store vectors, content and metadata into SQL Server or Azure SQL and then do simple similarity searches.test-2.py
: Read books reviews from a file, store it in SQL Server or Azure SQL, and then do similarity searches.
Build a semantic search engine over a PDF with document loaders, embedding models, and vector stores.
The tutorial described in the Build a semantic search engine page has been implemented in this project, but using the langchain_sqlserver
library.
The file ./semantic-search.py
contains the code of the tutorial. You can run it in your local environment. Make sure the create an .env
using .env.example
as a template.
The database used in the sample is named langchain
. Make sure you have permission to create tables in the database.
Introduces RAG and walks through a minimal implementation.
The tutorial described in the Build a Retrieval Augmented Generation (RAG) App: Part 1 page has been implemented in this project, but using the langchain_sqlserver
library.
The file ./rag-1.py
contains the code of the tutorial.
Extends the implementation to accommodate conversation-style interactions and multi-step retrieval processes.
The tutorial described in the Build a Retrieval Augmented Generation (RAG) App: Part 2 page has been implemented in this project, but using the langchain_sqlserver
library.
The file ./rag-2.py
contains the code of the tutorial.