Generate insert statement for SQL Server tables

SQL Server doesn’t have something like MySQL’s dump client built-in, which is really useful for backing up/recreating tables or the entire database. I know there are some good commercial tools to facilitate data export, such red-gate’s suite, but this is a very nice stored procedure that will generate insert statements you can use to repopulate another table.

http://vyaskn.tripod.com/code/generate_inserts.txt

It’s pretty flexible; it will accept quite a few different parameters that let you manipulate what records you actually want to create insert statements for. For my needs, I want to populate a few tables with only certain records. The sproc will let you can do something like:

EXEC sp_generate_inserts ‘project’, @From = “from project where projectID =1″

Lots of other ways to filter are also available..

Post a Comment

Your email is never published nor shared. Required fields are marked *

*

*