mssqldump, a small utility to dump MS SQL Server data

In the past few months I found myself busier with moving data here and there, so much that scripts ending with load(transform(extract())) have become my bread and butter — sad life, some say!

Last night I wanted to import a bunch of data stored in SQL Server into a MySQL database, but didn’t want to get my hards dirty with a GUI or PowerShell because, well, PowerShell.

The result was mssqldump, a small utility – similar to mysqldump – to export data into TSV.

Usage

mssqldump does one thing — and hopefully well — run a query against the database and export the results as TSV to the stdout:

1
2
3
4
5
6
./mssqldump -q "SELECT Name, 1 as ID, RAND() as thing from sys.Databases"
master    1    0.4318099474883688
tempdb    1    0.4318099474883688
model     1    0.4318099474883688
msdb      1    0.4318099474883688
test      1    0.4318099474883688

You can also include headings (column names) with the -c option:

1
2
3
4
5
6
7
./mssqldump -q "SELECT Name, 1 as ID, RAND() as thing from sys.Databases"
Name      ID   thing
master    1    0.4318099474883688
tempdb    1    0.4318099474883688
model     1    0.4318099474883688
msdb      1    0.4318099474883688
test      1    0.4318099474883688

If you want to print mssqldump’s version information you can just specify v or version as the query parameter:

1
2
./mssqldump -qversion
1.0.0

If you want to use mssqldump simply download the latest release from github and start dumping data around!

A couple surprises

Building mssqldump was an experience on its own, as I discovered a couple useful things:

Adios!


Hi there! I recently wrote an ebook on web application security, currently sold on leanpub, the Amazon Kindle store and gumroad.

It contains 160+ pages of content dedicated to securing web applications and improving your security awareness when building web apps, with chapters ranging from explaining how to secure HTTP cookies with the right flags to understanding why it is important to consider joining a bug bounty program.

Feel free to skim through some of the free chapters published on this blog and, if the content seems interesting enough to you, grab a copy on leanpub, the Amazon Kindle store, gumroad or simply checkout right down below!

Buy the Web Application Security ebook for $6.99

In the mood for some more reading?

...or check the archives.