Thursday, April 26, 2018

Use EXCEL to create SQL Insert Code

This script can be put into EXCEL to create Insert statements for SQL.  This will save a lot of time if you have data in EXCEL that needs to be put into a SQL table. 

This looks at 1 column and adds ' around data
="Insert into tmpCourses (Courses) VALUES ("&"'" & A1 & "'"& ");"

This looks at one column adding Text string before the data
="Insert into UserIDs (userid) VALUES ("& "'SCHOOL\"& A2 & "'"& ");"

This script looks at 3 columns
="Insert into Users (userid,first,last) VALUES ("& A2 & ","& CONCATENATE("'",B2,"'") &", "& CONCATENATE("'",C2,"'") &");"