Generate Insert Statements

Oopps! Upgrade your browser pretty please.Oopps! Upgrade your browser pretty please.

Ok, i might be the last person on earth to know about this but here it goes:

The other day a customer approached me with a question: ”Is there a way to generate insert statements, with the data included, for a specific table ?”
My immediate thought was that surely Management Studio incorporates this kind of functionality.

I started to right click on a table just to see what options there are.
Immediately i saw: Script Table as -> Insert To -> New Query Editor Window…
Alright here we go, another – soon to be, satisfied customer!
Well, not really…what i got was an insert statement with all the columns – INSERT INTO Table(Columns) VALUES(Columns), not the data.

So back to square one, regroup, rethink…

Next thing that came to mind was right click on the database -> Tasks -> Generate Scripts…

Another wizard starts. Here i chose to script a specific table and click next. In the next step in the wizard there is a button – ”Advanced” which shows us the Advanced Scripting Options.
Here i finally found what i was looking for: In ”Types of data to script” i can choose: ”Schema and data” which was exactly what i was looking for.

I finish the wizard and script the result to a new query window. And there is was, exactly as i wanted. Insert statements for every row in the table WITH the data.

There we go, another happy customer!