Generate sql insert script from excel worksheet

user2323240 picture user2323240 · May 29, 2013 · Viewed 428.8k times · Source

I have a large excel worksheet that I want to add to my database.

Can I generate an SQL insert script from this excel worksheet?

Answer

Hart CO picture Hart CO · May 29, 2013

I think importing using one of the methods mentioned is ideal if it truly is a large file, but you can use Excel to create insert statements:

="INSERT INTO table_name VALUES('"&A1&"','"&B1&"','"&C1&"')"

In MS SQL you can use:

SET NOCOUNT ON

To forego showing all the '1 row affected' comments. And if you are doing a lot of rows and it errors out, put a GO between statements every once in a while