Solved

SQL Query How do I mass update or insert?

Posted on 2008-06-16
3
3,154 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Introduction: Often, when running a query with joins, the results show up "duplicates", and often, those duplicates can be "eliminated" in the results using DISTINCT, for example. Using DISTINCT is simple: just add it after the SELECT keyword, an…
Read about achieving the basic levels of HRIS security in the workplace.
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…

746 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

13 Experts available now in Live!

Get 1:1 Help Now