KeyLimeTie Blog

SQL Server 2005 - Generate INSERT statements for easy migrations

By Brian Pautsch – 12/12/2006 11:01:19 PM. Posted to Code Snippets.

I often work in a local environment and later need to migrate data to a remote database server. If the ports are open on the remote server, I can just export the data. Often this is not the case. In the past, I have either
- Export the data, FTP it to the other location and import the data (what a pain!)
- Used code I wrote to export the data to INSERT statements, copy/paste text to other location and execute scripts (not too bad)

I was looking for an easier approach and came across Narayana Vyas Kondreddi's website. He has written a ton of code (VB and SQL) to do a lot of the everyday things we do.

Here's a link to a "Procedure to script your data (to generate INSERT statements from the existing data)":
http://vyaskn.tripod.com/code.htm#inserts

It's great. It installs in the master database and is available to all users for all databases.
It even has options to filter results, omit certain data types, get only n rows, and much more.
Be sure to check it out for yourself.

In case the site ever shuts down, here's a link to the SQL 2005 script.

Comments

On 1/8/2010 Daniel said:
I had already seen this earlier today, but I decided to look at some other solutions. After looking at your blog entry I gave it another shot. Works perfectly!

On 6/4/2008 Brian Pautsch said:
Thanks! We'll check it out. Always looking for a better product to use.

On 4/19/2008 Dan said:
One more suggestion: Try www.sqlscripter.com to generate Insert, Update, Delete scripts.

Leave a Comment

Name:
Email:
URL:
Comment:
Security Code:
Type Security Code:

Photos on Flickr

More Photos »

Search Blog


Get Email Updates

Like what you read here at KeyLimeTie? Sign up for our email list!

Subscribe