ChatGPT in SQL Server - Practical examples

  • Of course you don't TRUST the code from CoPilot.  You should not trust the code from anyone without testing it thoroughly first.  This is just a new advanced tool in it's earlyist iteration, treat it as such.

    But what has pending litigation got to do with the quality of the code produced?

  • cmgreenjr wrote:

    I was trying to reply to 3 different posts.  The way the responses showed up looks like i just put a similar answer 3 times together.

    If you want to do that, you're best of pressing the quote button; it's otherwise impossible to tell who you are replying to otherwise.

    Though there is no reason to reply 3 times (to different people in the same thread) with the same comment. 😉 These aren't DMs.

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
    Larnu.uk

  • cmgreenjr wrote:

    Of course it just makes positive statements.  It is a bot, it is not introspective.  It is just an advanced tool.  As with any tool it is up to the intelligent user to decide how and how much to use the tool.

    The issue here is that people are implying that it can be used in place of intelligent users.  You're also basing things on the wrong premise and assuming that "intelligent users" will be the users and that everyone will understand that it is just a bot.

    While I applaud the technology, it's "just" a summation of common knowledge, which is frequently incorrect.  It also only provides one "opinionated and confident answer" rather than multiple answers that would lead one to understand that some or all of the answers could be incorrect even if the code does return an accurate answer.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • cmgreenjr wrote:

    But what has pending litigation got to do with the quality of the code produced?

    Nothing.  The issue is "ethics" and Thom wasn't mixing the two concepts just because he made mention of that in the same post as a gripe about code quality.

    Heh... I have grounds to sue it, as well.  When I asked it how Jeff Moden would do it, it confidently delivered a method that I would never use, is grossly inferior to what I would actually use, and insisted the it's a method I would use.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • While I applaud the technology, it's "just" a summation of common knowledge, which is frequently incorrect.  It also only provides one "opinionated and confident answer" rather than multiple answers that would lead one to understand that some or all of the answers could be incorrect even if the code does return an accurate answer.[/quote-0]

    Just like I run into every day at work the quality of the answer is a product of the quality of the query.  I have no problem getting multiple answers as I stipulate in the query for it to give me the 5 BEST possible answers or TOP 5 answers, etc.

    And of course the world is still full of people trying to use a wrench as a hammer after a few thousand years.  The tool is but a tool, except when the user is.

  • cmgreenjr wrote:

    While I applaud the technology, it's "just" a summation of common knowledge, which is frequently incorrect.  It also only provides one "opinionated and confident answer" rather than multiple answers that would lead one to understand that some or all of the answers could be incorrect even if the code does return an accurate answer.[/quote-0]

    Just like I run into every day at work the quality of the answer is a product of the quality of the query.  I have no problem getting multiple answers as I stipulate in the query for it to give me the 5 BEST possible answers or TOP 5 answers, etc.

    And of course the world is still full of people trying to use a wrench as a hammer after a few thousand years.  The tool is but a tool, except when the user is.

    It sounds like you might be the right kind of user, then.  Most are not.  Most will take its "confident" sounding answers as gospel.

    As for me, I find that it takes too long to describe the problem to it and then have to check its answers.  I wouldn't "use it regularly" as many have suggested.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • As with other GPT coding experiences, both brilliant and stupid at the same time. The players table should not have the team in it. Firstly team name is unlikely to be the PK for teams (Joe Celko may disagree) but the association of a player with a team is a transient relationship and should therefore be in a team_player table with a team_id, player_id, signing_date, leave_date.

    The age calculator is wrong. DATEDIFF counts the number of 'ticks' between the dates.  Compare 31st December to 1st January will give you a DATEDIFF of one year.

    The lesson here is that GPT is brilliant for churning out MVP boilerplate code, but you still need to know what you are doing. As long as think of it like working with a (very) junior developer you should be OK

  • Awesome thoughts..it is first time i am seeing chat GPT with the SQL server...I dont have idea about ChatGpt before...Now I could understand about this...Thank you so much for posting this kind of extra ordinary information to people.

  • I did find a question that it answered mostly correctly...

    On the "simple" question of how to combine a DATE and a TIME column (I won't bore you with the entire conversation attempt), it failed miserably at all levels from asking as if in experienced to more detailed questions.  The reason I asked it that question is because I bumped into the question and was pretty well amazed at all the bad answers.  There are a lot of pit falls and it's likely one of the reasons why MS (finally) came out with DATETRUNC() in 2022.  One guy came up with the same answer that I did and he was poo-poo-ed because it's (mostly) "undocumented" in the SQL Server documentation.  I did some more experimenting and came up with some other related cool stuff.

    Getting back to this post, if you know how to think and how to write good T-SQL (accurate, performant, well documented with comments, and well formatted for readability), I'm pretty sure that you don't have to worry about ChatGTP taking your job. 😉  I'm also pretty sure that it's not going to help you look good at your job.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Jeff Moden wrote:

    Getting back to this post, if you know how to think and how to write good T-SQL (accurate, performant, well documented with comments, and well formatted for readability), I'm pretty sure that you don't have to worry about ChatGTP taking your job. 😉  I'm also pretty sure that it's not going to help you look good at your job.

     

    Hmm.... can it be used to explain politely but assertively to end users why their idiot idea is stupid and won't work?

  • ZZartin wrote:

    Jeff Moden wrote:

    Getting back to this post, if you know how to think and how to write good T-SQL (accurate, performant, well documented with comments, and well formatted for readability), I'm pretty sure that you don't have to worry about ChatGTP taking your job. 😉  I'm also pretty sure that it's not going to help you look good at your job.

    Hmm.... can it be used to explain politely but assertively to end users why their idiot idea is stupid and won't work?

    Why politely?

  • ZZartin wrote:

    Jeff Moden wrote:

    Getting back to this post, if you know how to think and how to write good T-SQL (accurate, performant, well documented with comments, and well formatted for readability), I'm pretty sure that you don't have to worry about ChatGTP taking your job. 😉  I'm also pretty sure that it's not going to help you look good at your job.

    Hmm.... can it be used to explain politely but assertively to end users why their idiot idea is stupid and won't work?

    I've given up on trying to do such things.  I try to explain once and then I quit because "A person forced against their will, is of the same opinion still).

    Instead, I've learned that the only way they learn is if they suffer by their own hand.  To wit, I am now in the mode of "Giving people the opportunity to fail".  That is not the same as "Setting someone up for failure".  I lay no booby-traps unless you consider me doing it exactly the way they've asked a booby-trap.

    I don't even tell them "I told you so" or "Are you ready to listen now"?  Instead, I calmly say "Let's try it this way", which is almost always the way I suggested it.  Of course, I also try to help the company bu frequently having what I believe is "the right way" done and ready to be tested.

    Then, I calmly walk outside... and chop a tree down.... with my bare hands. 😀

    The bad part is, I'm running out of trees that needed to be chopped down. 😀

    p.s.  The good part is that it usually only takes one occurrence for any given individual.  The really good part is that the word spreads when coworkers have lunch together, etc.  I might not run out of trees after all. 😀

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 12 posts - 16 through 26 (of 26 total)

You must be logged in to reply to this topic. Login to reply