Reputation: 47
Update: Would like something that everyone can use, not just admin.
I tried to find if this question has already been asked before this post. In SSMS 2014, is there an option to only allow query execution if any text has been selected?
If none is selected, F5 and/or the execution button should be disabled. Thank you!
Upvotes: 1
Views: 358
Reputation: 47
Based on my brief research, if user (like myself) who cannot run RAISERROR
with severity level 20 or above, I am using SET NOEXEC ON
and SET NOEXEC OFF
in the very top and bottom. Then develop your script inbetween those two statements.
The downside is that there are two statements to add at 2 different locations. Also, if your script requires the use of SET NOEXEC
, then this might not work.
Upvotes: 2
Reputation: 7928
I have this snippet that I sometimes include at the top of my queries:
raiserror('Highlight something and tell me what you''d like to do.', 20, -1) with log
Per the Microsoft Connect page titled, Add an Execute Selected Text Only to SQL Server Management Studio:
...We are considering adding this as a text-editor option for an upcoming release. I have no way to mark it as "added to backlog", so I'm resolving it as "Won't Fix". It's there though...
Cheers -Sam Hughes
That was in 2011. If there is a way to do this I suspect it would be using Redgate. I'm not a redgate guru but I know that, for example, SQL Prompt will throw a warning before letting you do a DELETE or UPDATE without a WHERE clause. That's where I'd start.
Upvotes: 0