Sreedhar Chintakunta Sreedhar Chintakunta - 5 months ago 75
SQL Question

Applying Quotes Across Multiple Lines in SSMS

Is there a keyboard function that applies single quotes across a list of values? I have 10 IDs that I have copied from an Excel spreadsheet and I would like to execute a query that uses an IN clause on this list, and I don't want to manually add single quotes and comma around each item.

For example:

SELECT * FROM tbl WHERE someValue IN (

I want to highlight the values and using a keyboard shortcut turn the list into:

SELECT * FROM tbl WHERE someValue IN (

I got how to get quote in the beginning using SHIFT + ALT (select the list and type single quote ')
Courtesy: Link.

But how to do the same at the end of each item to add a single quote and comma (',)

Thank you in advance


Place the cursor behind where you want to edit, press alt, then click and drag down. In your example you would place the cursor after the ABC1. click and drag till you get to ABC3. Then type ',