Include an option when reformatting SQL to automatically add semicolons at the end of each statement if they are missing.
While in most cases SQL Server 2005 and 2008 don't require this, the 2008 docs mention that a future version might.
and it may also be helpful if trying to move code from SQL Server 200x to a dialect which does require them.
This is included in SQL Prompt 6.4, which you can download from http://www.red-gate.com/products/sql-development/sql-prompt/
You can disable the semicolons being inserted on a format through the options under Format->Actions->Insert semicolons.
Is there an option to disable Automatic semicolons. I can't see it. For now I have uninstalled the new version and reverted to 6.1. It is driving me up the wall.
We have 30 licenses at the moment, and most of my guys are of the same opinion.
When you are in the middle of writing a complex query, formatting is useful, we do it several times as we keep adding to it. However you tend to keep tacking bits on the end and the semicolons get in the way.
When it is finished it would be good to have another option to add semicolons.
Eg Ctrl+K+Y work the same, then Ctrl+K+C could add the semicolons. But for now I’d prefer to ability to remove semicolons and add them in manually.
Klaus Ondrich commented
Yes, I know those snippets. We are using this awesome feature for code standardization (whole TRY/CATCH blocks with transactions and error handling within a snippet, for example), too.
I guess the problem with always putting semicolons after snippets is snippets aren't required to contain complete/valid sql statements, so Prompt might get this wrong. Eg imagine if someone had the snippet to insert a comment header, or create a couple of columns in a create table statement - in these cases Prompt could be more annoying than helpful.
Klaus Ondrich commented
Aaron, thanks for this feature. I think, it could be improved by automatically adding semicolons for each statement generated by snippets. So, ssf should expand to SELECT * FROM |; (where the pipe should indicate the position of the cursor) without the neet to add the semicolon to each snippet.
Thanks for the link!
I can confirm that this feature will be included in 6.4 - Hopefully we’ll have a beta build for it out in a few weeks.
Prompt won’t change the behaviour of the existing script so it won’t fix (or break) some of the sneaky cases mentioned in the blog post such as having an alias named “throw”. But hopefully the inserted semicolons will help make cases like that slightly easier to spot.
Always Use Semicolon Statement Terminators - From Dan Guzman's Blog
Benoit Levesque commented
Add this feature in SQL compare !
AdminDavid Simner (Admin, Redgate) commented
some statements require a GO either before or after them; it'd be really useful if these could be added automatically too!