SQL Prompt is a fantastic coding aid, but it does more than format your code and provide intellisense. Over time, the team has enhanced SQL Prompt to also guide you along and fix some bad code that your team might write out of habit.
SELECT arts.ArticlesID , arts.Title , arts.Description , arts.PublishDate , arts.URL FROM dbo.Articles AS arts WHERE arts.PublishDate > DATEADD(WEEK,-2,arts.PublishDate) ORDER BY 1
I don’t see this a lot from Microsoft stack developers, but PHP, Java, and some other languages will do this.
This has been deprecated, but it’s a poor practice as well. The dependency between the ordering and column list is not good. This is an easy place to make mistakes over time as code is refactored.
If I do this, SQL Prompt gives me a green squiggly line below the constant.
If I put the cursor here, I get a lightbulb in the sidebar. Clicking that will give you some options.
If I click the first item, this will give me a placeholder where I can choose a column. We could replace this with the first column in the column list, but if you detect this during refactoring, the first item from the column list might not be the one you want.
I can start typing and intellisense takes over.
It’s a small thing, but this is a one way that increases code quality for developers that might not know better.
If you haven’t tried SQL Prompt, download an eval and see what you think. If you have it, upgrade and ensure you have all the code fixes.