Sql-server – Applying single quotes across multiple lines using ssms code snippet

sql serversql-server-2012t-sql

further to Applying Quotes Across Multiple Lines

Is it possible to create a "surround with" ssms code snippet to turn a list of values across multiple lines into an IN clause, so I could:
select the list of values > right click > surround with > select the name of my code snippet in order to turn this:

SELECT * FROM tbl WHERE someValue
ABC1
ABC2
ABC3
ABC4

into this:

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

Best Answer

Yes. You can write your own snippets code in a .snippet file and then import it into SSMS. To import the folder containing the .snippet file:

  1. Open SSMS

  2. Click on Tools ->Code Snippets Manager

  3. Click on Add and select the folder where your custom snippets are written.

I believe this answers a part of your question. You can further follow the below links to get more details.

Adding Custom Snippets: http://www.sqlservercentral.com/articles/SSMS/138994/

About Snippets: https://www.mssqltips.com/sqlservertip/2411/getting-started-with-code-snippets-feature-of-sql-server-2012/