Solved

SQL Query How do I mass update or insert?

Posted on 2008-06-16
3
3,155 Views
Last Modified: 2012-08-14
I have an Excel sheet looks like this:
PartID MinQty MaxQty
Par1     10        20
Part2     15       20
Part3     20       30

I need to update this to database like:
PartID    Warehouse   MinQty      MaxQty
Part1         USA             0                0
Part1         USA             0                0
Part2  .............so on....................
Part2
Part3
I used below and worked, but I only can do this by one by one.
>>update tabl set minqty='10', maximumqty='20'
>>where partID='part1' and warehouse='USA'
Is there any way I can do this in batch?
I do not mind hand crafting Excel to txt etc.

0
Comment
Question by:creform
3 Comments
 
LVL 28

Accepted Solution

by:
Bill Bach earned 500 total points
ID: 21797490
Easiest way is to use a full-fledged ETL (extract/Transform/Load) tool, which could read Excel directly and update your records with the needed data.  I have used Pervasive's Data Integrator to do this (and I know that it could do it directly after about 5 minutes work), but this is a paid solution.  Might also be able to do with open source solutions Pentaho or JasperSoft.

Otherwise, the next best option is to save the Excel as CSV, then write a parser that parses the text and changes  it to UPDATE statements, then run all the statements through to the target database.

Might also be able to write a SQL query to the Excel/ODBC data source and have IT craft the statements for you, but this would be a bit more complicated to set up.

If this is a one-time thing, I'd recommend the latter two options.  If you'll need to do this on an ongoing basis, I'd recommend an ETL tool for the job.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
MS Access 2003 Query 2 52
Need a replacement data type in Oracle 6 66
Trigger usage 2 59
compare between entities in entity framework 8 12
I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
CCModeler offers a way to enter basic information like entities, attributes and relationships and export them as yEd or erviz diagram. It also can import existing Access or SQL Server tables with relationships.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now