Using Microsoft Excel to Generate SQL Scripts

Posted: October 14, 2010 in SQL Server 2005

If you have an excel spreadsheet that want to generate some quick SQL statements from, you can try the following:
Excel Spreadsheet
Say you have the following columns:

A B C SQL
MyFirstName MyLastName MyCity ="INSERT INTO tmp_table(first_name, last_name, city) VALUES('"&A1&"', '"&B1&"', '"&C1&"');"

SQL Script
You can add a column called SQL at the end of the last cell and enter the following text which will build your SQL script based on the columns you have entered:
="INSERT INTO tmp_table(first_name, last_name, city) VALUES('"&A1&"', '"&B1&"', '"&C1&"');"

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s