I am currently maintaining a significant number of SQL queries. Some of them are created by copy/paste operations, then removing unnecessary fields and sometimes forgetting to remove the tables where these fields come from.
I am looking for a tool (or anything apart from eyes+brain) that, given a SQL query, would analyze which of the joined tables have no field selected in the SELECT part.
Do you know of such a tool?
Thank you
You'll use INNER JOIN when you want to return only records having pair on both sides, and you'll use LEFT JOIN when you need all records from the “left” table, no matter if they have pair in the “right” table or not.
Using SQL Server Profiler (or SQL Server Extended Events and/or Auditing) to 'trace' or watch a SQL Server for a given amount of time, and then correlate a list of recently used/accessed objects against a full list of objects in a given database to get a feel for what hasn't been used in a while.
Hypothetically a tool could exist but it would only be guaranteed to be correct if all the following criteria where met for said join
Probably why there's no deterministic warnings in SQL parsers the way there is for let's say an unused variable in C#. But it might be worth while to create a SQL checker that looks for some of these conditions and lets the user know that there's a possibility for optimization here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With