Creating SQL Statements with Excel (Quick and Dirty)
Sometimes, you have to import predefined data supplied as a list, such as personnel numbers, into a database and at the same time provide it with additional (default) values. Creating each statement manually would be very time-consuming, especially for large amounts of data. The function “concatenate” in Excel helps a lot.
First, we pack all the values delivered as a list, in this simplified case personnel numbers, into the column one below the other.
In an adjacent column we add the function “concatenate” to create a character string:
=CONCATENATE(“INSERT INTO personal VALUES(“;A3;“,Value1,Value2,’01.01.2015′,Porta Westfalica, NULL)“)
The text written in red is taken over statically and the blue block automatically references the preceding column with the personnel number.
The result then looks like this and can be imported directly into the SQL management studio as a text copy: