GitHub Copilot - Our Best Ally for T-SQL

  • Nice and complete article, Daniel.  I, unfortunately, don't have the time to give it a try myself... at least now right now.

    What WOULD be interesting is to give it the 7 following problems to solve in the form of T-SQL.

    1. Solve the Fizz-Buzz problem.
    2. Solve the Fizz-Buss problem with scalability and resource usage in mind.
    3. Solve the Fizz-Buss problem with out producing any physical or logical reads. (p.s. Bing Chat said it's not possible in T-SQL but we all know better).
    4. Solve the Fizz-Buss problem for the entire numeric range of the INT datatype and insert the results into a permanent table that will have a clustered index on the column for the results.
    5. Same as question 4 but producing the least number of log file entries possible.
    6. You have a DATE datatype column and an TIME datatype column.  Combine them into a 3rd column.
    7. You have a UNIX TimeStamp with millisecond resolution.  Convert it to a DATETIME datatype with a resolution of 3 decimal places.

    I'd love to see the code it produces for those 7 problems.

    --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)

  • Can you include the link to the article that discusses how to install this? For those of us who missed it.

  • Post removed.

    --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)

  • I cannot find the article referenced: "Writing SQL Server code with AI using GitHub Copilot" that is supposed to discuss how to install CoPilot. After installing per GitHub general advice, there is no such thing as a right-click and chose Copilot> whatever

  • Comments posted to this topic are about the item GitHub Copilot - Our Best Ally for T-SQL

  • G Peterson wrote:

    I cannot find the article referenced: "Writing SQL Server code with AI using GitHub Copilot" that is supposed to discuss how to install CoPilot. After installing per GitHub general advice, there is no such thing as a right-click and chose Copilot> whatever

    I think you have to use Visual Studio Code, which I had never heard of. Once installed you can add the Copilot extension, authenticate against github and the right click options are there. You do need a subscription, I signed up for a 30 day trial. https://code.visualstudio.com/Download

  • Ed B wrote:

    G Peterson wrote:

    I cannot find the article referenced: "Writing SQL Server code with AI using GitHub Copilot" that is supposed to discuss how to install CoPilot. After installing per GitHub general advice, there is no such thing as a right-click and chose Copilot> whatever

    I think you have to use Visual Studio Code, which I had never heard of. Once installed you can add the Copilot extension, authenticate against github and the right click options are there. You do need a subscription, I signed up for a 30 day trial. https://code.visualstudio.com/Download%5B/quote%5D

    You can also use Azure Data Studio which is a more SQL friendly fork of Visual Studio Code if you want. That will also install and work with CoPilot. As with VSCode, just go to the Extensions tab, search for CoPilot. Install is easy from there.

     

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • Ed B wrote:

    G Peterson wrote:

    I cannot find the article referenced: "Writing SQL Server code with AI using GitHub Copilot" that is supposed to discuss how to install CoPilot. After installing per GitHub general advice, there is no such thing as a right-click and chose Copilot> whatever

    I think you have to use Visual Studio Code, which I had never heard of. Once installed you can add the Copilot extension, authenticate against github and the right click options are there. You do need a subscription, I signed up for a 30 day trial. https://code.visualstudio.com/Download%5B/quote%5D

    You can also use Azure Data Studio which is a more SQL friendly fork of Visual Studio Code if you want. That will also install and work with CoPilot. As with VSCode, just go to the Extensions tab, search for CoPilot. Install is easy from there.

     

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • I did give a try to ChatGPT about explaining SQL Code. Guthub Copilot is probably based on ChatGPT but more optimized at dealing with coding problems.

    It can explain the basis of SQL coding inside your procedure, especially when dealing with SQL metadata views or functions.

    But it can’t explain the business rules you are processing, in your query, and you could not expect ChatGpt neither Copilot to do so. It uses cleverly the comments that are already there to infer more explanations.

    I also tried to push it to adopt a programming pattern for queries. It was tough to get the whole function right as I want. In the end, it explained nicely what I was trying to communicate to him. Due to lack of time, I couldn’t ask him to write another function using the same pattern, so I didn’t know if it really learned.

    What is interesting also, is that it writes some fancy skeleton code.

Viewing 9 posts - 1 through 8 (of 8 total)

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