jeudi 26 mars 2015

Applying Quotes Across Multiple Lines


In SQL Server Management Studio you can use the shortcut CTRL + K > C or CTRL + K > U to comment/uncomment lines in bulk.


Is there a similar keyboard function that applies single quotes across a list of values? I have 150 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 dont want to manually add single quotes and comma around each item.


For example:



SELECT * FROM tbl WHERE someValue IN (
ABC1
ABC2
ABC3
ABC4
)


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



SELECT * FROM tbl WHERE someValue IN (
'ABC1',
'ABC2',
'ABC3',
'ABC4'
)




Aucun commentaire:

Enregistrer un commentaire