SSMS Tip: Auto-generate Insert Statements

Once again, leaving a note to myself.

Do you remember when SQL Server’s import/export functionality didn’t suck?  Where, when you didn’t have direct connectivity between two instances, you could export data to a flat file from the source server and then import them into the target server, and not have to deal with annoying conversion or cast errors due to the nature of the data, the rotation of the Earth around the Sun, and other random problems?

I ran into this issue when trying to copy reference data from one server’s reference tables into another’s (where the schema already existed), and just constantly running into these issues.

Luckily, there’s StackOverflow, which had this.

Basically, on a database, you can use Tasks –> Generate Scripts to choose to copy data only and it will generate your insert statements for you (and handle identity columns, yada yada yada).

Obviously, if you need it, this works for more than just reference data.

posted on Tuesday, August 13, 2013 11:18 PM Print
No comments posted yet.

Post Comment

Title *
Name *
Comment *  
Please add 5 and 3 and type the answer here: