Blog Post

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.

Original post (opens in new tab)
View comments in original post (opens in new tab)

Rate

You rated this post out of 5. Change rating

Share

Share

Rate

You rated this post out of 5. Change rating