Execute Current Statement
Currently required to highlight query text to run one statement in one instance of a query window. This is a bit of a nuisance. I have used TOAD for SQL Server in the past and I could just position my cursor within a single sql statement and execute the current statement only and not all sql statements within the current query window instance. The latter method seems to be much more efficient for those of us administrators with a bunch of sql statements in one query window and just wishing to run select statements.
Upvotes: 7<=-=Jun 6 2005 8:24AM=-=>
Thank you for your suggestion regarding executing a statement without having to select it. We will consider this for future releases.
This hasn’t made it into a service pack, but we’re still considering this item for a future release of SQL Server.
Paul A. Mestemaker II
Microsoft SQL Server Manageability
Although we won’t be able to provide this functionality for SQL Server 2008, we can consider it for a future release based on overall customer demand.
Ken Van Hyning
Like the OP I’ve used TOAD and been really impressed with this feature. Would really like to have this in SSMS.
I raised a forum thread on it prior to coming here: http://social.msdn.microsoft.com/Forums/en-US/sqltools/thread/4fcd052d-a2db-4431-b80f-9a2ca278ff8a/
This submisison is now 4 years old – is it worth my raising it again?
I’m not sure about this one. Until everyone is always ending every single statement with a proper terminator (;) it can become very messy trying to figure out what the “current statement” is.
The feature in the PowerShell ISE always throws me off but in the other direction. You can highlight a line of code but if you hit F5 it still executes everything, because you didn’t choose the “exec current statement” option.
I prefer the way SSMS does it today. F5 always executes exactly what you have selected.<=-=Apr 9 2013 3:27PM=-=>
Not just Toad, but every other visual SQL Query tool I’ve used over the past few years against Oracle, Sybase – even DB2 – has some way to do this. Don’t get me wrong – I am very happy to be back working with MSSQL, but I was actually shocked that this seemly simple feature still hasn’t made it into production.
Not suggesting you change the default function of F5 or Ctrl-E, but please give us some other shortcut to access this behaviour: CRTL-ALT-SHIFT whatever would be fine.
For the comments below referring to people not terminating their statements correctly, the expected behaviour in these other tools (and by the way – some of them are terrible) is that if the current statement can’t be identified, then error – pretty much the same thing that would happen if you try to run a collection of un-terminated statements.
Mads Bjerre commented
When you have tried it in Toad, you feel you cannot live without it.
There is an opensource add-on that does it, just cannot get it to work with latest version.
Please add this fantastic feature.
Michael Nady commented
I was about to add the same suggestion. I was forced to work with Oracle Sql Developer for a while then I am back to Sql Server. This is likely to be the most missed feature for me.
If the issue is with putting a semicolon at the end of the statement you can just raise an error if the user tries to run the current statement when it doens't end with a semicolon.
the shortcut Ctrl+Enter would be great for this, just as in Sql Developer.
This is already an old request, please try to review it again.