Sql-server – Generating an insert script based on selected rows in Sql Server

databasescriptingsql server

In Sql Server 2005, is there any way, using the official GUI or a third party tool, to select rows in a table and then generate a insert script for the selected rows?

Best Answer

I do not know of tool that lets you do this using a nice GUI, but I do know of a nice stored procedure that you can use to generate inserts, based on select statement. The script was created by a guy named Narayana Vyas Kondreddi.

You can learn more about the script here.

You would use it like this:

EXEC sp_generate_inserts 'titles', @From = "from titles where title like '%Computer%'"

It's a real time-saver.

Related Topic