theq
theq

Reputation: 111

Execute SQL Statement from cursor position without selecting like F8 in PowerShell

I'm using VSCode with the ms-sql extension.

I'd like to execute a sql statement without selecting it. So I have eg

Select that from 
this

go
select more 

fro|m there

where valid = 1

go

The cursor is on the position '|' and if I hit a specific key (like F8 in PowerShell) it would execute the second SQL Statement. The Cursor position could be anywhere in the code. Could this work anyhow?

Upvotes: 2

Views: 659

Answers (1)

theq
theq

Reputation: 111

Since I have been downvoted I thought, maybe it is easier than thought. And yes, there is a command built out of the box. Only add the following to keybindings.json and it works:

{
"key": "f8",
"command": "mssql.runCurrentStatement",
"when": "editorTextFocus && editorLangId == 'sql'"
}

Upvotes: 1

Related Questions