Data using excel in the rapid generation of sql statement

In small companies, then there will always be developed to import historical data (data migration from the old system to the new system) time. This time, on-site implementation or customer will give you an EXCEL file, which contains some historical data on other systems, then let you import to the current system to go above.

Not to mention the different table data structure, this process will be able to coordinate with plenty of space to tell a story, just to have assumed that the historical data on other systems fit into the current system has become a sort of data. How to do this work efficiently import, it is the topic discussed here: the use of data EXECL table quickly generate SQL statements.

Because the data is imported into the new data is inserted inside the table, thus using the INSERT statement.

INSERT INTO TABLE(COLUMN1, COLUMN2, ...) VALUES(VALUE1, VALUE2, ...);

So what is the secret to quickly generate the INSERT statement is? The answer is powerful and fast formula for automatic filling EXCEL.

Here a simple example to make the user table with a simple structure.

user table has two fields, is a code, is a name.

In a given EXCEL, these two fields correspond to columns C and column D, the data start from the second line, then we can start writing from the second line, the new line at the end of the second one to hold formula.

Posted formula:

=CONCATENATE("insert into user(code, name) values('",C2, "','", D2, "');")

Then click the Enter will generate the corresponding INSERT statements in accordance with the formula.

Then, the focus here, hover your mouse over the lower right corner of the current formula cell, when the lower-right corner becomes a plus sign, drag down, the system will automatically fill in these equations a.

Finally, these generate a good INSERT statement copied to the console tool or database tool to perform just fine, EXCEL selected in all the cells in the current column down the shortcut key is the content of [ctrl + shift + ↓], and then use the cv Dafa on the line. When the presence of thousands of data in EXCEL, efficiency is manifested.

Of course, in addition to the INSERT statement, you can write other SQL statements, according to the specific needs flexible enough, it is important to know this method.

More, but also there are many other scenarios apply, use EXCEL data processing skills, this one is very important, the time still have to learn this knowledge.

 

"All you have experienced hard, have the opportunity to tell you love ta, ta let know you love ta, ta let the courage to face life's twists around."

Guess you like

Origin www.cnblogs.com/yanggb/p/11101634.html