In SQL Server Management Studio 2008, I tends to write a lot of queries in a single window and execute a single line of them whenever I need. Hence a shortcut to highlight a sentence is kind of helping a lot.

I've tried all combination of the following but no luck.
Ctrl+Alt+Down

Ctrl+Shift+Down

Alt+Shift+Down

有帮助吗?

解决方案 2

Home Shift+End would do it. I doubt there is a need for anything shorter

其他提示

This selects the whole line as well:

CTRL + KU

Note that if the line is commented, it also removes the comment

By the way, you can copy (or cut) an entire line by just pressing CTRL+C and CTRL+X without having any selection.

Same should work in Visual Studio and other good text editors.

Building on @iagowp's clever suggestion of using a side-effect of the Uncomment command, you can assign the shortcut key of your choice for selecting a line.

I use Ctrl+L.

By default this is mapped to Edit.LineCut in some SSMS editors. I use Ctrl+X for that, so I remapped it, but you can choose any key combination you like.

It's worth going over how to assign shortcut keys, as it's really, really easy but can be confusing at first. I'm very glad I made the effort, as it's a doddle now and having relevant shortcuts can be a real boost. These are the steps:

  1. From Tools, Options, select Keyboard (under Environment). There's a lot of magic on this dialog but for now, head straight for Show commands containing and (remembering we're going to map a key to the Uncomment Selection command) start to type "uncomment" till the command is selected in the list below:

enter image description here

  1. Beneath the list we can see any shortcuts currently mapped to the command, and whether each mapping is Global. This is where things can start to seem confusing but if we open the dropdown of shortcuts for this command, things start to make sense:

enter image description here

Here we see that this command can be executed in the DataWarehouse Designer using the shortcut Ctrl+K, Ctrl+U. We see that the same shortcut can be used in the Text Editor. Finally, we see that the same shortcut can be used anywhere in SSMS (it's Global), so in fact these specific mappings for DataWarehouse Designer and Text Editor are redundant (which we could demonstrate by removing them, using the button alongside—but we won't do that just now.)

  1. Under Press shortcut keys, click the box to give it focus, then press your chosen shortcut keys on the keyboard (Ctrl+L in this example):

enter image description here

Our desired shortcut may well already be in use, and the final dropdown shows any existing commands it's mapped to. Here we see that Ctrl+L is used for Edit.LineCut in one designer, and for the same command in one editor, but for something quite different in SQL Query Editor. It has no Global mapping at present.

enter image description here

Alongside the Press shortcut keys box is the Assign button. Before pressing Assign to map the new shortcut to the command, there's one final choice to make. In the Use new shortcut in dropdown on the left, we can control the scope of the shortcut. We could choose Global, but since it's overriden in SQL Query Editor, our shortcut wouldn't then work in that editor. For this example, we'll choose SQL Query Editor.

enter image description here (At this point the Press shortcut keys part has to be done again. Normally it's best to set the scope first, which avoids this glitch. The sequence we followed in this example was just for introducing the concepts.)

As a final check, if we enter the shortcut keys one last time and open the dropdown, we can see that SSMS has replaced the previous SQL Query Editor mapping with our new one.

enter image description here

We're good to go! From now on, pressing Ctrl+L with no selection will select the current line in SQL Query Editor.

Shift+Home will do the job perfectly.

I use: Home Shift+

Might look too many strokes, but it is fast enough.

I would just use

Fn + Shift +

I am using that in SQLite Studio and crl + alt + down do the work for me. you just have to place your mouse pointer to the end of the line, my System is windows 10 other systems may vary!.

SHIFT + END will do the job as expected

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top