Generating INSERT statements in SQL Server

01/27/09

Permalink 08:57:46 pm, by truewill Email , 236 words, 383 views   English (US)
Categories: Tips, Testing, Tools, SQL

Generating INSERT statements in SQL Server

For anyone who has ever used MySQL, SQL Server really seems to be missing the ability to export data as a series of INSERT statements.

A number of people have tried to remedy this. Here’s one I tried today:

InsertGenerator

This worked for what I needed. It seems to be limited to certain data types, and you do have to tweak Management Studio as noted in the comments: “select Tools, Options, select the Results tab then change the ‘Maximum characters per column:’ value to something bigger than 256″.

As for how I’m using it, I had a SQL Server Express file-based database set up as a test deck for some of our O/RM business objects. Some of the test methods change the data, and I wanted them to be independent. I set up the table data as I wanted it, ran the Insert Generator, then saved the INSERT statements to a stored procedure preceded with TRUNCATE TABLE. I then changed the SetUp test fixture to call the stored procedure.

I don’t like having to use a physical database to run the tests. With the way our O/RM persistence framework works, though, it’s difficult to avoid that.

I certainly wouldn’t recommend this stored procedure for production code. It worked fine for my test code, though.

There are a number of similar implementations. If anyone has a recommendation on the quintessential one, please post a comment!

Comments, Pingbacks:

Comment from: Taner Ozdas [Visitor] Email · http://www.mysqlnedir.com
In my opinion MSSQL's strored procedure is powerfull than MySQL. Because when i use stored procedure in MySQL i don't see the performance differences with tsql. Did you have change to benchmark ?
PermalinkPermalink 03/23/10 @ 15:13

Leave a comment:

Your email address will not be displayed on this site.
Your URL will be displayed.

Allowed XHTML tags: <p, ul, ol, li, dl, dt, dd, address, blockquote, ins, del, span, bdo, br, em, strong, dfn, code, samp, kdb, var, cite, abbr, acronym, q, sub, sup, tt, i, b, big, small>
(Line breaks become <br />)
(Set cookies for name, email and url)
(Allow users to contact you through a message form (your email will NOT be displayed.))
The name truewill is composed of two other words. What is the SECOND word?

Development Central

Development Central is the blog of Bill Sorensen, a professional software developer. Much of this will relate to C#, .NET, and OOP in general.

Disclaimer
These postings are provided "AS IS" with no warranties and confer no rights.

Search

Categories

Linkblog

b2evolution

contributors

XML Feeds

What is RSS?

Who's Online?

  • Guest Users: 10

powered by b2evolution free blog software