Search code examples
ssms

Is there a way to set SSMS only allows to run when code is selected


I am pretty new to SSMS and I am starting to make scripts. Sometimes I click on Run without selecting my code and you can imagine that it has consequences on the database.

I wanted to ask you if there is a possible configuration on SSMS so that the run button is not accessible when we have code selected?

Kind Regards


Solution

  • Setting SET NOEXEC ON before the query guaranties that the SQL Server engine will check the syntax and object reference errors (during compilation), but it will not execute the actual query.

    If you want prevent distract F5 or EXEC without have checked if you're executing something dangerous, put it before each script that you are making.