Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
    
So instead of a generic insert you want the data specific to the selected row(s), correct? –  squillman Jul 1 '09 at 14:41
    
Right. My issue is that I insert rows with the SQL Server GUI and then want to copy inserted rows to other servers. –  James McMahon Jul 1 '09 at 14:46

3 Answers 3

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.

share|improve this answer

SQuirreL SQL can do this:

Highlight a SELECT statement, then invoke Session/Scripts/Create data script from SQL.

share|improve this answer
    
I can only get SQuirrel to copy specific columns from the rows into an insert, not the entire row. –  James McMahon Jul 1 '09 at 18:25
    
Hm, if you do something like "SELECT * from tableA", then mark the whole statement with the mouse and invoke the menu option given above, it should work. How did you do it? –  sleske Jul 1 '09 at 22:58
    
I'm having the same problem: Squirrel won't give me an INSERT script on a select(*) –  George Jempty Oct 18 '12 at 18:54

I would recommend you to use SQL Tool Belt from RedGate link text

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.