I have what is probably a rather unusual question. Is there a T-SQL tool that requires using a semicolon to terminate statements? I know that it's not required to use semicolons with SQL Server 2008 R1, which is what I'm connecting to, but I actually would like to be forced to use it for running update queries. I'm sure we're all aware of the dangers of writing a query like the one below in the middle of a sql pad, and then highlighting it and running it (which is unfortunately something I tend to do a lot):
UPDATE dbo.Customers
SET ZipCode = '40223'
WHERE Name = 'Bob Loblaw'
… because you only have to miss-select your text once to nuke all your customer's zipcodes!
So, ideally, I'd like to continue doing most of my sql work in SQL Server Management Studio, but have a separate pad open (in a tool that requires semicolons) and only allow myself to write data manipulation queries over there. This would give me great peace of mind, because I'd know I could never miss-select my commonly used update queries. If I did, it wouldn't run, because it wouldn't have a semicolon.
Best Answer
Rather than relying on semicolons (a misplaced semicolon could also cause the problem you are describing), better to rely on transactions.
Set up your query tool to require a commit, and you will have the option rollback if necessary.
In SSMS, you can do this by checking the option
SET IMPLICIT TRANSACTIONS
under Tools/Options/Query Execution/SQL Server/ANSI. Or, you can turn it on with this command:SET IMPLICIT_TRANSACTIONS (Transact-SQL)