Tag: AIExperiments

  • Copilot Outside of SSMS Seems to Work

    I read Brent’s first look at SSMS and Copilot in there. He didn’t have a great opinion of the tool, especially comparing it to Gemini or Claude. I haven’t tested this yet, mostly because I’ve got other stuff going on, but I decided to take his prompt and the code and drop it into the dedicated Copilot App on my Windows 11 laptop.

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

    I have a button that starts Copilot, so I pressed it and put in this prompt:

    2025-05_line0075

    This was copied from Brent’s post, and then his code copied and dropped in.

    I was curious to see if this worked.

    My Results

    I thought my results were better. The first part of the response is shown below. Copilot sees the scalar function as a problem and rewrites things. I don’t love that this is just the query and not the CREATE OR ALTER PROC part, but still.

    2025-05_line0073

    Below this, it notes that I should test indexes and gives me the ones it would recommend. Then it goes into the fact that order by desc can be problematic. It also has a TOP 1 recommendation for the first query.

    2025-05_line0074

    The rest of the response is OK, and gets into some general things that might help me go past the recommendations.

    2025-05_line0076

    The prompting matters, as if I click on the “what are more perf opt techniques” I get a lot of generic stuff.

    2025-05_line0078

    Is AI going to make you a better DBA or developer? Maybe. It will give you things to think about, but you need to test them. You might even ask a GenAI tool for help on that. I did and got this:

    2025-05_line0079

    And below, some more steps.

    2025-05_line0080

    Not bad, and likely what a lot of people do, though perhaps not with #5, in which HammerDB is suggested to run this proc.

    Learn to use GenAI tools, learn where they help (And save time) and where they can’t be trusted. That’s likely an ongoing battle for most of us, but these tools can help us be more productive.

  • Using AI to Test a SQL Query

    Someone sent me this code.

    WITH p AS
     ( SELECT ID, ROW_NUMBER() OVER (ORDER BY ID ASC) AS RN
     FROM wp_posts
     WHERE post_parent = 94341; )
     UPDATE p SET menu_order = RN

    That’s not great code. In fact, it won’t run. I know that, but does an AI? Let’s see how Copilot does.

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

    The First Test

    I entered this prompt, but accidentally hit Enter. When I then pasted in the code and hit enter, I got this:

    2025-05_line0012

    That is just about what I would have sent the author to let them know this code doesn’t work. It’s good to see a GenAI LLM can recognize this.

    I then pasted in the entire prompt which was: “give me a table with the schema to match this code: WITH p AS ( SELECT ID, ROW_NUMBER() OVER (ORDER BY ID ASC) AS RN FROM wp_posts WHERE post_parent = 94341; ) UPDATE p SET menu_order = RN

    The Gen AI response was polite, with this answer:

    Certainly! Based on your SQL code, it looks like you need a table schema that matches the structure of wp_posts, particularly including ID, post_parent, and menu_order. Here’s a possible schema:

    I then had this code, with a copy button that I could copy/paste into SSMS.

    CREATE TABLE wp_posts (
         ID INT PRIMARY KEY,      -- Unique identifier for each post
         post_parent INT,         -- Parent post ID (for hierarchical structures)
         menu_order INT           -- Order value for arranging posts
    );

    That’s what I would have done to mock this up for testing. You might guess the next step: data.

    Here’s my prompt: create some test data for the table with Ids that increment but are not necessarily sequential and post_parent values that match the ID values

    That got my this response.

    2025-05_line0016

    That’s not bad, but it’s a limited set of data. Let’s ask for more.

    2025-05_line0031

    Below this the GenAI LLM gave me a summary that explains what it did.

    2025-05_line0032

    Next, I wanted a test. I used this prompt: write a tsqlt test to verify that the update statement works to reset the menu_order to sequential values for a particular post_parent

    I got a nice response and the code I’m showing below the image.

    2025-05_line0033

    Here is the code:

    -- Step 1: Create a test class
    EXEC tSQLt.NewTestClass 'TestMenuOrderUpdate';

    GO

     

    — Step 2: Define the test
    CREATE PROCEDURE TestMenuOrderUpdate.[test_UpdateMenuOrder_Sequential]
    AS
    BEGIN
    — Arrange: Fake the wp_posts table
    EXEC tSQLt.FakeTable ‘dbo.wp_posts’;

     

    INSERT INTO wp_posts (ID, post_parent, menu_order)
    VALUES
    (101, 94341, 5), (102, 94341, 3), (103, 94341, 8),
    (104, 94341, 1), (105, 94341, 7);

     

    — Act: Run the update logic
    WITH p AS (
    SELECT ID, ROW_NUMBER() OVER (ORDER BY ID ASC) AS RN
    FROM wp_posts
    WHERE post_parent = 94341
    )
    UPDATE wp_posts
    SET menu_order = p.RN
    FROM p
    WHERE wp_posts.ID = p.ID;

     

    — Assert: Check if menu_order is sequential
    EXEC tSQLt.AssertEqualsTable ‘ExpectedResults’, ‘wp_posts’;

     

    END;
    GO

     

    — Step 3: Create expected results table for assertion
    CREATE TABLE ExpectedResults (
    ID INT PRIMARY KEY,
    post_parent INT,
    menu_order INT
    );

     

    INSERT INTO ExpectedResults (ID, post_parent, menu_order)
    VALUES
    (101, 94341, 1), (102, 94341, 2), (103, 94341, 3),
    (104, 94341, 4), (105, 94341, 5);

     

    — Run the test
    EXEC tSQLt.Run ‘TestMenuOrderUpdate’;

    
    

    This is where I stopped. This code runs, though it’s brittle in that the Expected Results table is a real table and not a temp inside the test. I can easily edit that and likely quicker than the GenAI can. It’s copy/pasting some code for me from one spot to another. I also need to add a CREATE OR ALTER to the proc.

    Summary

    A quick use of an AI that easily saved me 5-10 minutes to mock of a scenario and show someone what they were doing wrong and also testing their code. I mock up things regularly to test them, and often do something like this to answer questions. This is a good place where AI can save some time, and might be worth using. I’m also glad to see it recognize and write some decent SQL code for me, especially the insert statement for test data.

  • Checking Myself with GenAI

    I had a suggestion from somone on a place where AI helps them and I decided to try it. The person had an AI summarize their work and if the result wasn’t the intention of the author, then they know know their writing wasn’t clear.

    This post looks at how that worked for me.

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

    Checking an Editorial

    I wrote an editorial on database Devops that was published recently. I decided to have a few AIs summarize this and see if the result was what I intended. First up, Claude, with a simple prompt: summarize this text (insert here). See the top of the prompt here:

    2025-05_line0025

    The result is shown below and seems to be an accurate summary of the text. This is basically what I was trying to say in the piece. Of course, this isn’t much shorter than the text, but this gives me confidence here in the ability to recognize what I’ve written.

    2025-05_line0027

    In Perplexity, I got this result. This result is similar, but doesn’t mention the author. Instead, this is a summary of the text, not trying to give a voice to the author, which is interesting. Very close to the text above, but this seems slightly drier, taking the text as fact rather than opinion.

    2025-05_line0026

    Perplexity also had some related items at the bottom, which injected a prompt back into the LLM for more info.

    2025-05_line0029

    Last, Copilot. I have a dedicated key on my laptop for this and I pressed it and entered my prompt in the app. This result is shorter and to the point. There are some additional links to click that the bottom.

    2025-05_line0028

    Clicking on one of the items at the bottom injects the text and gets a new result.

    2025-05_line0030

    I tried this with a couple other piece of work, some of which aren’t published. In each case (3 attempts), the summary made sense. I don’t know if that means I am writing anything clearly, but it does help me get a sense of what I’ve written.

  • Can an AI Help Me Find a Job?

    I’m not looking for a job, but I ran across an article about using AI tools for a job search. So I decided to try it out. I followed a couple of those prompts and get some results. Here is a set of things I did.

    Salary Calculators

    I ran this prompt from the article: What are some of the best salary calculators for a Data/SQL Server professional? Provide a list of your top 4 recommendations and the pros and cons of each one. Provide any helpful links. Format as a table.

    The results? Mixed. Here is what I got from my local Deepseek model. Note, I didn’t get a table.

    2025-03_0123

    From Claude:

    2025-03_0124

    From Perplexity

    2025-03_0125

    Are these helpful? Well, I knew about GlassDoor and the BLS. Didn’t know Robert Half has a calculator. If I had done this a few years ago, I would have Googled this. When I did, I saw Payscale, Zippia, and CompTia. Ziprecruiter had hourly salaries, US News had a link. None of the ones in the table were there.

    Both the Payscale link (Google) and Robert Half gave me similar results. Is the AI more helpful? It gave me a few things to think about, but it didn’t find some of the top Google links. Not sure what to think about that.

    My Worth

    I decided to ask this prompt: I am a senior database administrator with over 20 years of experience working with SQL Server in large and small companies, handling a variety of operational responsibilities. I have developed and implemented high availability solutions, automated server builds, understand DevOps style database development and GitOps management of servers. I have managed replication, built ETL pipelines, and implemented role-based access controls. What is the market value of my skill set?

    The local model didn’t really help here. It gives me some generic things to think about and consider, and some ideas of where to look, but no real links.

    Claude:

    2025-03_0127

    Perplexity:

    2025-03_0128

    Adding Skills

    From claude:

    2025-03_0129

    And perplexity:

    2025-03_0131

    Those are interesting ideas. I’m sure I could follow this up and get more details on some of these and perhaps kickstart my learning. These are areas an AI might be helpful to help guide you or develop a plan. Certainly a friend might do this, but it’s tedious work. Getting some links, assembling a plan, etc.

    Claude builds a detailed plan on the right side and describes it on the left The plan has a lot of links to documentation for tools below the phases:

    2025-03_0133

    Preplexity gives me a plan, with links as footnotes.

    2025-03_0132

    Negotiation

    I used this prompt as is from the article: I am making $98,000 with 3 weeks of PTO now. I want to ask for an 8% raise and an additional week of PTO. I also want to work from home one more day a week, especially if I can’t get any extra PTO. What guidance do you have for making this request? What other rate negotiation best practices should I keep in mind?

    Claude: a decent plan to get prepare.

    2025-03_0135

    Perplexity: very similar results

    2025-03_0136

    This isn’t a lot different from advice I’d give, but I wouldn’t write this all down. If someone told me this, I might forget some things. A plan is always good, and the AI has given me a decent plan. I might copy this and run it by friends, who are more likely to mark it up or add to it rather than build the whole thing.

    It’s an assistant to getting started and a pretty good one.

    A Cover Letter

    These are a pain, and I always struggle to get one moving. Here are the results from this prompt:  Given my experience, help me write a cover letter to apply for a DBA job

    Claude: Again, an explanation on the left and a result I can start with on the right. It’s  a bit wordy and AI-like, but I can adjust that.

    2025-03_0137

    Perplexity: Simpler, but effective.

    2025-03_0138

    Note, I didn’t paste anything else in, the AI remembered my experience from earlier in the chat. That’s way, way, way better than working through a search engine.

    Summary

    For most of us, (I hope) searching for a job is a rare thing. It’s always a pain, and it can be stressful. It’s also easy not to be organized and forget things. A GenAI can assist you with more patience than your friends or family might have. It can give you a good start, but please don’t just copy/paste this stuff or follow it blindly. Ask fellow humans what they think of these recommendations.

    The GenAI models are trained on lots of data, and they can function as a sounding board, but they aren’t bringing creativity, and your answers will look a lot like other people’s answers. Lots of people will use an LLM to help them here, so make sure you tweak things to stand out a bit.

    And build your brand, and let GenAI help you. Don’t let it write blog posts, but it can sketch things out that you edit and clean up. That editing and cleanup skill will help you in interviews and jobs, so don’t forget to polish the final product yourself. Let the GenAI be an assistant that gets you started and that’s it.