January 19, 2024 at 12:00 am
Comments posted to this topic are about the item Leveraging AI Tools for SQL Queries
January 19, 2024 at 5:01 am
Not aimed at the author but aimed at the whole concept... Let's look at the first example prompt in the article...
You are an SQL Server database developer. Assume you are working with the AdventureWorks2022 sample database. Write the SQL code to create a view named vwPersonDetails with columns Title FirstName, MiddleName, LastName, and JobTitle from the Person and Employee tables of HumanResources schema.
Including the single spaces, that took 294 characters of typing and esoteric memory of column and table names because there was no use of "intellesense" etc. "Look how easy that was"??? NOT easy compared to something like SQL Prompt or even (ugh!) Intellisense or even click'n'drag from the object explorer. It's easier to type a part of something and have SQL Prompt or Intellisense fill in the rest.
And, even if you didn't have any of that, the you still had to know all the names of the columns and tables and the prompt ended up being a total of 294 characters of typing instead of just the 247 in the code. And, guess what? You don't need to copy and paste the code to run it and you don't need to read an explanation because... you were smart enough to write it in the first place and it didn't take any more knowledge than to build that prompt. In fact, SQL Prompt or Intellisense probably wrote half the code for you.
AI just made extra work here. I'll put a good developer up against even themself and the one that doesn't us AI, is going to get it done first.
--Jeff Moden
Change is inevitable... Change for the better is not.
January 19, 2024 at 9:48 am
Adventureworks is a publicly available DB designed to show off SQL Server. As such it has sensible naming standards and PK/FKs.
Is there a capability that would work against DBs that are not visible publicly and whose SQL source code is kept private too?
I was in a client meeting when the observation was made about the value of increasing resources for a particular activity. Basically there are two types
Jeff's comment made me think of the 2nd one.
There are AI products out there that can do a discovery piece on your databases and infer PK/FK relationships and others. I am quietly optimistic that these will offer data people a valuable service.
I'm uncomfortable with ChatGPT. I've found that a lot of its answers are believable rather than correct.
January 19, 2024 at 10:04 am
Not aimed at the author but aimed at the whole concept... Let's look at the first example prompt in the article...
You are an SQL Server database developer. Assume you are working with the AdventureWorks2022 sample database. Write the SQL code to create a view named vwPersonDetails with columns Title FirstName, MiddleName, LastName, and JobTitle from the Person and Employee tables of HumanResources schema.
Including the single spaces, that took 294 characters of typing and esoteric memory of column and table names because there was no use of "intellesense" etc. "Look how easy that was"??? NOT easy compared to something like SQL Prompt or even (ugh!) Intellisense or even click'n'drag from the object explorer. It's easier to type a part of something and have SQL Prompt or Intellisense fill in the rest.
And, even if you didn't have any of that, the you still had to know all the names of the columns and tables and the prompt ended up being a total of 294 characters of typing instead of just the 247 in the code. And, guess what? You don't need to copy and paste the code to run it and you don't need to read an explanation because... you were smart enough to write it in the first place and it didn't take any more knowledge than to build that prompt. In fact, SQL Prompt or Intellisense probably wrote half the code for you.
AI just made extra work here. I'll put a good developer up against even themself and the one that doesn't us AI, is going to get it done first.
In the version of ChatGPT I use you can create a list of predefined prompts. So you just select a suitable prompt from a list then type the question. So if you are using it on a regular basis for SQL Server you can set a list of predefined prompts like:
"You are a SQL Server developer and will add comments to the code I provide. The format of comments is [give your example here]".
Then just select that prompt, paste the code in and it will add comments to the code.
January 19, 2024 at 1:15 pm
While the AI is quite capable of explaining exactly WHAT the code does programmatically, it's simply not capable of figuring out the WHY for most code. For example, the AI will explain quite nicely that the code is giving a 10% discount to something but it is not generally capable of determining WHY the 10% discount is being given.
Heh... and I couldn't believe the part of the article that said you could check the accuracy of the code by copying it to another AI and asking what it does. Why not just copy the code to SSMS and press the bloody {F5} key in a test environment?
While I think that AI is a huge technological advancement, I think people have already gone stupid in it's use in a lot of areas. This article is a perfect example of how that is already happening.
And, again, that's no reflection on the author of this article.
--Jeff Moden
Change is inevitable... Change for the better is not.
January 19, 2024 at 1:19 pm
I'm uncomfortable with ChatGPT. I've found that a lot of its answers are believable rather than correct.
Exactly. I summarize that as being "Confidently Incorrect" and, in that area, ChatGPT has come to the point of perfectly matching many people in that aspect... and they make me uncomfortable, as well.
--Jeff Moden
Change is inevitable... Change for the better is not.
January 19, 2024 at 1:55 pm
David.Poole wrote:I'm uncomfortable with ChatGPT. I've found that a lot of its answers are believable rather than correct.
Exactly. I summarize that as being "Confidently Incorrect" and, in that area, ChatGPT has come to the point of perfectly matching many people in that aspect... and they make me uncomfortable, as well.
I look at it a bit like having a junior assistant that you can set work to but then have to check the results.
January 19, 2024 at 2:42 pm
AdventureWorks has been around a long time and every aspect of its data model has been crawled and indexed. How well do ChatGPT and Bard do on an undocumented DB, assuming its data model is fairly well built out?
January 19, 2024 at 5:12 pm
I think the "explanation" of the table it gives speaks volumes to its limitations. Explaining:
These are not helpful and just a waste. A lot of software designers do this. If they have a setting called "Advanced Measurements ON/OFF", when you click the help it says, "Select ON to enable Advanced Measurements". I know this. I want to know what advanced measurements does. If you're not going to explain anything helpful, don't make the "help" available.
August 19, 2024 at 1:15 pm
OrderPrice
for the month of September. Please use the following tables in the query: Sales.[Order]
as o
, Sales.OrderDetail
as od
, Sales.Customer
as c
, and Sales.Shipper
as s
.LowestOrderPrices
with the value 'Lowest Order Prices'
.SeptemberOrders
by extracting the year and month (YYYY-09
) from the o.OrderDate
.OrderPrice
by calculating the product of od.UnitPrice
and od.Quantity
.DiscountedOrderPrice
by applying the discount percentage to the OrderPrice
.DaysFromOrderToShip
as the difference in days between o.OrderDate
and o.ShippedDate
.OrderPrice
in ascending order and limit the results to the 10 lowest orders.
I really liked your article, thank you. In the explanation using "Order and Limit: The query is ordered by OrderPrice and limited to the 10 lowest orders using OFFSET and FETCH." instead of the proprietary Top 10
August 19, 2024 at 1:15 pm
OrderPrice
for the month of September. Please use the following tables in the query: Sales.[Order]
as o
, Sales.OrderDetail
as od
, Sales.Customer
as c
, and Sales.Shipper
as s
.LowestOrderPrices
with the value 'Lowest Order Prices'
.SeptemberOrders
by extracting the year and month (YYYY-09
) from the o.OrderDate
.OrderPrice
by calculating the product of od.UnitPrice
and od.Quantity
.DiscountedOrderPrice
by applying the discount percentage to the OrderPrice
.DaysFromOrderToShip
as the difference in days between o.OrderDate
and o.ShippedDate
.OrderPrice
in ascending order and limit the results to the 10 lowest orders.
I really liked your article, thank you. In the explanation using "Order and Limit: The query is ordered by OrderPrice and limited to the 10 lowest orders using OFFSET and FETCH." instead of the proprietary Top 10
August 19, 2024 at 1:15 pm
OrderPrice
for the month of September. Please use the following tables in the query: Sales.[Order]
as o
, Sales.OrderDetail
as od
, Sales.Customer
as c
, and Sales.Shipper
as s
.LowestOrderPrices
with the value 'Lowest Order Prices'
.SeptemberOrders
by extracting the year and month (YYYY-09
) from the o.OrderDate
.OrderPrice
by calculating the product of od.UnitPrice
and od.Quantity
.DiscountedOrderPrice
by applying the discount percentage to the OrderPrice
.DaysFromOrderToShip
as the difference in days between o.OrderDate
and o.ShippedDate
.OrderPrice
in ascending order and limit the results to the 10 lowest orders.
I really liked your article, thank you. In the explanation using "Order and Limit: The query is ordered by OrderPrice and limited to the 10 lowest orders using OFFSET and FETCH." instead of the proprietary Top 10
August 19, 2024 at 1:29 pm
This was an excellent article in exploring the iterative prompt engineering. Also, consider looking into https://ollama.com/ for private LLM's or Huggingfaces.com. Look into medium.com for ideas on AI and the vast amount tools out there.
2B9B
Viewing 13 posts - 1 through 12 (of 12 total)
You must be logged in to reply to this topic. Login to reply