Export SQL as Insert Statements

Sometimes you just want to dump the contents of a database table as a series of insert statements. Many DBMSes can do this, in fact I do it with MySQL all the time. But it seems Microsoft SQL Server Enterprise Manager can’t do it. Oh you can export the create table statement. But that’s it. Why? It seems like a glaring omission. Almost like good old Microsoft is trying to make it as difficult as possible to migrate your data to another DBMS. So stupid. But we will always find a way… so I wrote an ASP script that’ll do what I needed. Here it is for you to use.

Be aware that it has not been fully tested on all database column types. And, it should not be left on your server or even accessible to the general public- the script is a security concern since I did add some basic sql injection handling, but it is really only very half-assed because this was for one time use by myself only. I recommend you keep this script in a password protected directory. And delete it when you’re done.

I don’t really like ASP very much. I strongly prefer to work in a PHP-MySQL environment. So, if the code isn’t pretty, it’s because I’m new at this.

If you find it useful, please add your comments here. And also post a comment if you have any improvements to recommend. Thanks!

So without further delay, here is my quick and dirty ASP T-SQL Insert Statement Generator. It makes use of ADO to connect to an MsSQL database:

Download Zip File