开发者

Add-In for keyboard shortcut to select current block or execute current block in sql server management studio query window?

开发者 https://www.devze.com 2023-03-06 01:31 出处:网络
In TOAD, you have k开发者_C百科eyboard shortcuts where you can select the current block or execute the current block....so if you are working on a large sql query, when you make a modification, you ca

In TOAD, you have k开发者_C百科eyboard shortcuts where you can select the current block or execute the current block....so if you are working on a large sql query, when you make a modification, you can just do a CTRL+ENTER (or something like that, can't recall right now) rather than having to manually highlight the block of sql and htting F5.

I'm pretty sure this doesn't exist natively in SSMS, anyone know if functionality like this exists in any Add-ins?

Sorry....some clarification....I'm talking about working in the query window, which may contain:

select * from SomeTable

select * from SomeTable
WHERE
    column1 = 'abc'
AND column2 = 'def'  <--- LET'S SAY MY CURSOR IS SITTING HERE
AND column3 = 'ghi'

select * from AnotherTable
WHERE
    column1 = 'abc'
AND column2 = 'def'
AND column3 = 'ghi'

So, I just want to execute the statement that my cursor is within.


The add-in SQL Complete has this exact feature. Execute current statement without selecting it. Their free express version has it, but I also recommend standard version for its additional features. It's a major time-saver.


OK, so to clarify what you're looking for... If you had the following T-SQL with text selection cursor as indicated:

DECLARE @Test Int
SET @Test = 1

IF @Test=1
BEGIN
    SELECT TestColumn1 FROM TestTable
    SELECT AnotherTestColumn FROM AnotherTestTable

    SELECT [A Valid Column]

    FROM [A Valid Table]

    SELECT LastColumn FROM LastTable ][ <- CURSOR HERE
END

You would want a certain hotkey (eg Ctrl-F5) to execute SELECT LastColumn FROM LastTable...? Or SELECT LastColumn FROM LastTable END (which is what you would get with the blank row rule you described)? Or something else? How about the statement broken up with a line break in the middle, or the two statements bunched together?

If you really wanted to use blank rows to define "blocks", then that should be pretty easy to do as an Addin (sample/tutorial here); if, on the other hand, you expected a little more "intelligence", this could be a difficult/complex task, with SQL parsing required etc.


Would love to see this feature added to ssms query analyzer. I'm a long-time toad user.

The closest thing I've found is to highlight the query using directional arrows and then hit f5. Toad allows you to execute a query merely by placing the cursor anywhere within the query and then hit cntl+enter. It doesn't sound like much of an efficiency save but I really miss it.


You can check out this add-in for SSMS 2012. Place the cursor within the statement you want to execute and press CTRL+SHIFT+E

SSMS Executor - http://ssmsexecutor.codeplex.com/


Not certain I'm following your wording, but, do you mean:

Select text down line by line starting from the cursor SHIFT+ DOWN ARROW

Execute the selected portion of the query editor or the entire query editor if nothing is selected F5 or CTRL+E or ALT+X

Parse the selected portion of the query editor or the entire query editor if nothing is selected

CTRL+F5

MSDN SSMS keyboard shortcuts


I develop SSMSBoost add-in and we have recently added Shift-F5 (Select current statement), which, followed by F5 (Execute) will execute current statement. It works in all versions of SSMS from 2008R2 till latest 18.1

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号