Convert SQL to CSV in Notepad++


SQL Script can be converted to CSV format using Notepad++ Editor using few simple steps using Find and Replace option. As no regular expressions are to be used, we can achieve this even with editors that do not have them.

Let's take a sample SQL script,

insert into my_sql_table (id,name,marks) values ('1','Joe','66');
insert into my_sql_table (id,name,marks) values ('2','Mark','45');
insert into my_sql_table (id,name,marks) values ('3','Steve','23');
insert into my_sql_table (id,name,marks) values ('4','Larry','57');
insert into my_sql_table (id,name,marks) values ('5','Smith','78');

Steps to Convert SQL Script to CSV Format

Step 1 : Copy the fields values to a separate tab.

Step 2: Press Ctrl + F to open find and replace dialog, and move to replace the tag, see to it that search mode is Normal. Now Find insert into my_sql_table (id,name,marks) values ( and replace with Blank.

Find and Replace at start of query.jpg
Find and Replace at start of query.jpg

Step 3 : Now we need to find ); and replace with ;

Find and Replace the EOL.jpg
Find and Replace the EOL.jpg

Step 4: Now we have our CSV format almost ready, just copy the Step 1: copied Table fields at the top of the file, the result is CSV.

SQL now converted to CSV format.jpg
SQL now converted to CSV format.jpg





Hello there!,

You are using AdBlocker!

I am an independent developer trying to help fellow developers and students to resolve issues faced on a day-to-day basis, we 'Code to Care' . There is a lot of expenses involved in hosting and managing a website that's the reason we have ads.

A humble request to you to disable adBlocker on Code2care.org and support us pay our bills.

Thanks,
Cod2care - Line's of code for change.

To see contents reload page after unblocking
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, Video Tutorials, Code Snippets, Tips-n-tricks, How Tos, Blogs, Articles, etc. on various platforms like Windows, Mac, Linux, Mobile platforms, etc. Technologies/Languages like Java, Objective-C, PHP, .Net, Android, SharePoint, jQuery, HTML, CSS, etc.