A regional bank needed to score loan applicants for default risk in real time — directly within their existing SQL Server environment. By integrating Azure Machine Learning with SQL Server Machine Learning Services, predictive models were operationalized inside the database itself, eliminating data movement and delivering sub-second risk scores at the point of decision.
The bank's loan underwriting team was using a static, rules-based scoring model built in Excel over a decade ago. The model hadn't been retrained since 2019, was producing increasingly inaccurate risk scores, and required loan officers to manually copy applicant data from SQL Server into the spreadsheet to generate a score — a process taking 15-20 minutes per application and introducing transcription errors.
The risk team wanted a machine learning model but had strict data governance requirements: applicant data could not be sent to external APIs or cloud services for scoring. The model had to run entirely within the bank's existing SQL Server infrastructure.
Activated the Python runtime within SQL Server Machine Learning Services on the existing on-premises SQL Server instance — allowing Python scripts to execute directly inside T-SQL stored procedures with full access to database tables, no data movement required.
Used Azure Machine Learning to train a gradient boosting classification model on 5 years of historical loan application data — including applicant demographics, credit bureau features, employment history, and loan performance outcomes. The model achieved an AUC of 0.91 on the holdout test set, significantly outperforming the legacy rules-based model.
Serialized the trained Azure ML model as a binary object and stored it directly in a SQL Server model registry table. A T-SQL stored procedure — written with Copilot for Azure Data assistance — loads the model from the registry and executes Python scoring logic in-process, returning a risk score and probability band for any applicant record passed to it.
Modified the loan origination application to call the SQL Server scoring stored procedure at the point of application submission — returning a real-time risk score, probability of default, and a plain-English risk tier (Low / Medium / High / Decline) within the existing workflow, with no changes to the application's UI required.
Configured a SQL Server Agent job to extract monthly loan performance data and push it to Azure Machine Learning via Azure Data Factory, triggering automated model retraining when prediction drift exceeded a defined threshold — keeping the model current without manual intervention. Power BI dashboards track model accuracy and score distribution over time.
Let's discuss how AI-enhanced SQL Server & T-SQL Development can deliver similar results for your organization.
Start the Conversation