How to Convert CSV file to SQL Script using Notepad++

If you have a .csv file and you want to convert it into an SQL insert Query (be MySql, SQLite, Oracle), this can be done in just a few simple steps using Notepad++ Find and Replace with some Regular Expressions.

GIF showing csv to sql script using Notepad++
GIF showing csv to sql script using Notepad++
  1. Open the CSV (Comma Separated Values) file in Notepad++
  2. Our Sample CSV Data :

  3. Enclose each data values in CSV file with Single Quotes.
  4. Open Find and Replace by pressing "Ctrl + F", go to replace tab and,

    Find : ,
    Replace with : ','

    Result :


    Now data values are enclosed with Quotes, expect the row start and end. For this we need to use Regular Expression.

  5. Forming the Query
  6. Go to Find and Replace,
    Find : ^
    Replace : insert insert myTable values\('
    ^ is a regex character to add data at the start of each line in the file. Keep in mind to select "Regular Expression" in Search Mode. \ (slash) is an escape character for braces in the regex. Result :
    insert insert myTable values('1','data1','data-a','323
    insert insert myTable values('2','data2','data-b','324
    insert insert myTable values('3','data3','data-a','325
    insert insert myTable values('4','data4','data-b','326
    insert insert myTable values('5','data5','data-a','327
    insert insert myTable values('6','data6','data-b','328
  7. Now lets complete the Sql script.
  8. Go to Find and Replace again and,

    Find : $
    Replace : '\);

    Make sure that you select "Regular Expression" in Search Mode. \ (slash) is an escape character for braces in regex.

    Result :

    insert insert myTable values('1','data1','data-a','323');
    insert insert myTable values('2','data2','data-b','324');
    insert insert myTable values('3','data3','data-a','325');
    insert insert myTable values('4','data4','data-b','326');
    insert insert myTable values('5','data5','data-a','327');
    insert insert myTable values('6','data6','data-b','328');

    $ is a regex character to add data at the end of each line in file.

    Thats it!! Our SQL Script is now ready!..

    Note: Data may not be as simple as we have considered in our example. We may have Single Quotes (') in within itself, So in such cases, you need to first escape it by,

    Find : '
    Replace : ''

    ⚠️ Remember to move search mode in "Regular Expression" while using RegEx or else you may not get results.

Try Out Code2care Dev Tools:


Android Java Linux Microsoft Google Python macOS Notepad++ Microsoft Teams CSS PHP SharePoint Html Linux C Programs Bootstrap jQuery Sublime Android Studio Facebook Eclipse WhatsApp News MySQL Json HowTos JavaScript FTP S3


Code2care is an initiative to publish and share varied knowledge in programming and technical areas gathered during day-to-day learnings and development activities.

Students and Software Developers can leverage this portal to find solutions to their various queries without re-inventing the wheel by referring to our easy to understand posts. Technical posts might include Learnings, Tutorials, Trouble-Shooting steps, Video Tutorials, Code Snippets, How Tos, Blogs, Articles, etc.
🎉 We are celebrating the 10th years of Code2care! Thank you for all your support! We hope we made a difference.
We strong support Gender Equality & Diversity.

We stand in solidarity with Ukraine - Make a donation to UNHCR -