Vscode-mssql: Support executing a query around the cursor

Created on 6 Jan 2017  路  8Comments  路  Source: microsoft/vscode-mssql

the runQuery command is very useful and works for 2 out of the 3 scenarios i use - It either executes everything in the file if nothing is selected, or just the selected part.

I'd like support for the 3rd scenario - run only the query around the cursor location. For example, If i have a file with N SELECT statements and the cursor is currently at a specific one (probably detectable by the standard seperators) - Execute only that.

backlog enhancement

Most helpful comment

Thanks for clarifying. We'll keep this as a backlog work item for now and assess vs. some of the other user-requested fixes and improvements in our upcoming sprint plans.

Incidentally, this is the kind of issue that is excellent for external commiters if anyone is interested in taking it on - it's focused, can be done without impacting other areas and just requires knowledge of VSCode editor APIs and our execute query API.

All 8 comments

By standard separator, do you mean the GO batch separator, or detecting just the current statement (a single SELECT statement for example) with semicolon or other delimiter?

I was thinking of the latter, but either (or both) would be great.
I often have quite a few statements that are along the same schema or general group of tables and views, but only need a few or even one at a time.

I usually go about commenting the rest in and out as i go, but that's very tedious.

Thanks for clarifying. We'll keep this as a backlog work item for now and assess vs. some of the other user-requested fixes and improvements in our upcoming sprint plans.

Incidentally, this is the kind of issue that is excellent for external commiters if anyone is interested in taking it on - it's focused, can be done without impacting other areas and just requires knowledge of VSCode editor APIs and our execute query API.

Is Microsoft/sqltoolsservice#217 related to this? If so, Sounds promising..

@ransagy an implementation for this suggestion is available in this private build https://github.com/Microsoft/vscode-mssql/issues/870 and will be in out next release. Please let me know if there are any issues with the feature.

I've been using it for a few days, Working rather great so far.
I have had a certain issue with 'empty' SQL (comments, etc, where no actual command is in the current statement), but haven't been able to repro. I'll open a new bug if i can.

I also have one suggestion on this - that 'Execute Current Statement' should behave the same as 'Execute Query' when something is selected - That is, Execute the selected portion. This might merit a different issue for the feature suggestion, let me know and i'll open one.

@ransagy today's build fixes a couple issues with running the command with no SQL statement available at current cursor position. Please open an issue if you continue to see anything unexpected there.

Regarding behavior with a current selection, my thinking was there is already an existing command to execute only the current selection (i.e. "Execute Query") so having this command behave the same would be (1) redundant with Execute Query (2) incorrectly named since the command is "execute current statement" and in this case we wouldn't be executing only the current statement.

Is your use case you only want to always use "Execute Current Statement" so switching between the two commands in the different use cases cumbersome? In any case, if you open an issue with the specific scenario you have in mind I can go over the details with our PMs. Thanks!

Cool, I'll give that a try then. I'll open a new issue for the scenario i'm thinking about.

EDIT: opened Microsoft/vscode-mssql#946.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

GhostBasenji picture GhostBasenji  路  5Comments

casraysa picture casraysa  路  7Comments

henksandoval picture henksandoval  路  6Comments

haydnlj picture haydnlj  路  7Comments

jasperdunn picture jasperdunn  路  8Comments