Converting Chained CTEs to Temporary Tables Using ChatGPT
When it comes to readability, I prefer CTEs to derived tables. Something about reading top-down clicks in my brain. However, when I'm debugging a series of chained CTEs, I often convert them to temporary tables to see what is happening at each link in the chain. In the past, the complexity of the expressions influenced my decision to refactor them because of the time required.
I started asking ChatGPT to help me with this refactoring, and it has saved me a lot of time, which means I'm more likely to do it—one less friction point in the troubleshooting process.