Category: Blog

  • Prompt AI helping with Auditing

    I had a conversation with a customer asking this question: how can I tell who called a stored procedure so I can audit the action?

    I decided to see if Prompt could help me here.

    This is part of a series of experiments with AI systems. This is also part of a series of posts on SQL Prompt. You can see all my posts on SQL Prompt under that tag.

    The Setup

    I had this code, which is a simple stored procedure. I sketched this out, but I’m looking for a function to add to my code that helps me audit the caller.

    2025-09_0128

    I opened the Prompt AI (ALT+Z) and asked the question you see in the image. I also asked to assign it to the variable, but didn’t exactly specify everything.

    2025-09_0129

    In the image below, you can see the code that changed. Prompt AI added the System_User function, which is exactly what I wanted.

    2025-09_0130

    I accepted this and then asked to change this to the user instead of the login.

    2025-09_0131

    Again, the function I wanted was added: CURRENT_USER.

    2025-09_0132

    I know what I needed, or I had an idea. However, if I wasn’t sure what function to use or if there was one, this is handy. I’m working inline, rather than going to a browser and hitting Books Online or Googling for the answer. I can keep coding or looking at my code as the AI runs.

    If I ask for an explanation, I get one, which helps me judge if this is actually the code I want.

    2025-09_0133

    If you have SQL Prompt, get Prompt AI a try by opening it with ALT+Z.

    If you haven’t tried SQL Prompt, download the eval and give it a try. I think you’ll find this is one of the best tools to increase your productivity writing SQL.

    Video Walkthrough

    I show this live in the video below.

  • Adding a Local Model to Ollama through the GUI

    I saw some good reviews of the small gemma3 model in a few places and wanted to try it locally. This

    If you want to get started, read my post on setting up a Local LLM. This post gives an alternative to connecting to the container from the CLI and running a command.

    This is part of a series of experiments with AI systems.

    Adding a Model

    Using the Ollama-WebUI server, it’s easy to add models. I wrote about setting up the UI and I’m running that as my interface to the local model. I created a new container for this post, so when I see the interface, there are no models to choose from. You can see this below.

    2025-09_0090

    I need a model because if I try to ask a question, I get an error that the model is not selected. You can see the error at the top in this image and the query at the bottom.

    2025-09_0091

    If I click the gear icon by the model drop down, I get a list of settings. One of these is “Models”, which is third on the left.

    2025-09_0092

    I click Models and get this list. As you can see I have no models. Notice I need a model name to enter. However, where the cursor is below, there is a “click here” for a list of models.

    2025-09_0094

    This opens the Ollama site at https://ollama.com/library

    2025-09_0095

    If I scroll down, I see the gemma3 model. If I click this I see a few different ones. I am not a big fan of latest, but this is a test. I decided to just grab it since I’m not programming things.

    2025-09_0097

    If I enter this in my WebUI and click download, it starts downloading.

    2025-09_0098

    Progress is shown, and it’s not quick. I went on to other work and this is the view about 15 minutes later.

    2025-09_0100

    Once this is complete, I close settings and see my model in the list. Since this is the only model for this container, I’ll click “set as default”.

    2025-09_0102

    Now I can get my fun fact:

    2025-09_0103

    Now I have a safe, secure, local model to use. If you want to see this run in real-time, check out this video:

  • T-SQL Tuesday #191: Invitation–Your Favorite String Parsing

    It’s that time of the month, and I’m late. My apologies. I had a mix-up with a host and was on vacation all last week, so no invite.

    I’m extending T-SQL Tuesday #191 a week to have people write on Oct 21, 2025. My apologies. The invite is below, something that’s been on my mind with all the AI work I’ve been doing, but I thought I’d ask about something more SQL related.

    I’m looking for hosts for 2026. Blogging is a great way to grow your brand and help you impress potential future employers.

    Your Favorite String Parsing Routines

    One of the things that I’ve had to do a log in my career is parse strings in different ways. It seems our customers constantly find new ways to stick data into a string that we would prefer to have normalized in some way for searching, indexing, etc.

    As a few examples, we might get someone who creates a PO that looks like 20260720321433, where there’s a year/month to start and then a number. We might need to parse either the number or the date from the field to determine when or which count of a PO someone has made. Other examples might be someone putting “Sam Jones” in the last name (surname) column because there isn’t a middle name space. We might need to get just the last name out of the field.

    This year (2025) I’ve been using AI often to try and get data from various structures, often PDFs or more complex formats, but I have managed to ask AI to change a bunch of data in a field across different rows rather than try and work out some RegEx search and replace. That got me thinking.

    What are your favorite string parsing routines that have helped you handle complex situations? That’s your invite for Oct 2025. Write on a way that you’ve handled parsing (and maybe replacing values) in complex strings.

    I see questions on things all the time at SQL Server Central. A few examples:

    • [Doe, Jane E] [Doe Smith, Jane E] (get the without middle/initials/etc)
    • [Hello5-E-100] (get the final number)
    • 192.168.1.100 – parse IPv4 (or v6) addresses
    • Parse XML for a value
    • Parse JSON for a value
    • [8/9/08 – out for upgrade; 8/16/08 returned to inventory. 8/31/2008 – deployed to field] – parse out all the dates

    Write on Oct 21, 2025, a week late, and post a comment on this post linking back to your entry. I’ll compile everything next week for the roundup. The rules:

    • Publish the post before 2025-10-21 11:59:59
    • Include the logo above
    • Link the logo to this invite
    • Make a comment on this post (or trackback/linkback)
  • A Short Break

    It’s holiday week for me. I was in the Netherlands last week for Pass on Tour and the Redgate Summit. My wife joined me and we are taking a break this week, wandering around Northern Italy.

    See you next week. Hopefully refreshed and recharged.