SQL Clone
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in

SQL Server - Generate SQL INSERT from Excel

Generate SQL Server INSERT statements with Excel Concatenate.

A developer requested  access to a Production database. The details were to COPY and PASTE from a Excel spreadsheet into Access , which then updated SQL Server.  Upon asking him , why he used this method , he said “It’s the way I always insert this data to the lookup table”.

There are better ways . One way , is to use the “Concatenate” function in Excel.  It concatenates the ascii portions of the statement, adding single quotes where relevant.

In this example , there are four rows with the values in col A and B.  Create the formula for the first line, the copy to  the rest of the lines.

Copy and Paste the the INSERT statements directly into SQL Server Management Studio or create a text file.


See Also

Powershell , Excel charts and data presentation

Excel Connect to SQL Server


Leave a comment on the original post [www.sqlserver-dba.com, opens in a new window]

Loading comments...