marți, 12 august 2025

Quickly Format a List for SQL IN Clause Using Notepad++

Let’s say I have a list of strings:

STRING1
STRING2
...
STRING200

And I want to create a query like:

SELECT count(*) 
FROM TABLE 
WHERE COLUMN IN ('STRING1', 'STRING2', ..., 'STRING200');

Quick solution using Notepad++:

  1. Open the file in Notepad++.
  2. In the Find what field, enter:
    ^(.*)$
    
  3. In the Replace with field, enter:
    '$1',
  4. Set Search Mode to Regular expression.
  5. Click Replace All.
This will wrap each string in quotes and add a trailing comma, so you can paste it directly into your SQL IN clause.

Niciun comentariu:

Trimiteți un comentariu