Generating SQL INSERT from data in Excel file - sql

I have a spreadsheet with thousands of records. Columns correspond to fields in a table in a SQL Server database. What is the quickest way to generate an SQL query to insert this data?

#Al2110
based on your query, To generating SQL insert from data in excel file that show in below:
insert into customers values('" &B3 &"','" &C3& "','"&D3&"');
I hope above information will be useful for you.
Thank you.

SQL Server Import and Export Wizard is a convenient option.

Related

How to Bulk Insert to a SQL table from Lotusscript Agent

I need upload over 10,000 records into a sql table from a lotusscript agent. Is there a way I can bulk load them? Excel file attachment is an option if I can do it that way. But I have to use lotusscript agent.
Refer to the answers to this question: Insert multiple rows WITHOUT repeating the "INSERT INTO ..." part of the statement?
First figure out what the correct syntax for providing values to a multiple record INSERT is in the particular SQL dialect that you are working with, and then write your LotusScript code to read your data values (from Excel, or from whatever the actual source is) and produce insert them into the right places in a string containing your SQL INSERT syntax. Then submit that SQL string to your database server.

Best practice for data migration

Currently We have developed a system for a manual work they have been doing using many excel files.
Is there a best practice for data migration? because I wanted to use backend language like .net to do the validation and insert into tables rather than using SQL to do migration.
Total record in excel is around 12K rows but for many tables so its not needed consider a lot about performance and it is only one time.
I would add a few calculated columns in Excel that would generate SQL Insert / Update scripts. Something like ="INSERT INTO table (column) VALUES ('"&A1&"');"
Then just copy calculated column and run it through SQL client. I used to have a macros to run it directly from Excel through OLEDB that would highlight failed expressions and store SQL Exceptions next to them.
That way the data can be easily tidied, corrected and SQL re-run as needed.

SQL query for copying table data to Excel file

Is there any SQL query for copying an Oracle database table's data into an Excel file?
Please let me know if there are any. Thanks
You could look into query2sheet for PL/SQL (Oracle)
https://technology.amis.nl/2011/02/19/create-an-excel-file-with-plsql/

Export Excel table to sql using VBA

Can anyone point me to an example for exporting an excel table into an sql table, assuming the same structure, using VBA? I'm using Excel 2007. I've seen examples that read the data one row at a time and either run one insert per row, or build their recordset, and do UpdateBatch. Is there a way where I can select all record from the source table in excel and insert them all into the target sql table?
Bulk Insert is what you are looking for.
Try these:
Stackoverflow question
Bulk Insert - social msdn
Other way is to import in sql management studio
Import Excel spreadsheet columns into SQL Server database

Modify data in MSAccess before passing on to SQL Table

I have set up an Access database with a linked table to an SQL table. I've created a query in Access off the linked table. I have shipping software that i've set up to export data to the Access query and it successfully gets passed on to the SQL Table. So far, so good.
Now to the issue. The "weight" column in the SQL table has an "implied" 4 decimal places. So when I export a weight of "1", it shows up in the SQL table as ".0001". I need to multiply the weight by 10000 in order to get it to show up as "1.0000" in the SQL table.
I've tried modifying the Query's SELECT statement to do the math on that column but I get a "Cannot Update Field" error out of the ODBC driver.
Is there a way to make this happen? I'm not using MS Access at all (other than to create the .mdb file). Just using the .mdb file as a bridge between the shipping application and the SQL table.
Thanks for any guidance!
Look at this answer which looks very similar to what you are looking for.
https://stackoverflow.com/a/11296097/886591