Solved

Nightly Imports using DTS or Incremental Updating

Posted on 2004-08-11
6
438 Views
Last Modified: 2008-03-06
I am trying to update a table using DTS.  Here is the setup

1. AS/400 Machine with DB/2
2. MS SQL 2000

Constraints.

I am actually updating invoice history, since querying against the as/400 takes too long, so I decided to move the history files over to the SQL Server to improve performance.  The history dates back quite a bit.

There are errors in the dates, ie. something could have been invoiced July 2006, (the year is wrong) ... As my original idea was just to select the max date on the SQL Server, then select all invoices past that date on the as400.

The invoice numbers are also erronous.

So, I am left with two choices.

1. Complete import of the table during off hours ( 2:00 am)
2. figure out some way of incremental updates. The best solution.

Can someone walk me through how to create/deploy a DTS package that can do this?  Or, if there is a better way than DTS please let me know.
0
Comment
Question by:2xhelix
  • 3
  • 3
6 Comments
 
LVL 34

Expert Comment

by:arbert
ID: 11772768
How much information are you talking about?  You said the invoice date can be wrong--is there an add date or a change date on the records?
0
 

Author Comment

by:2xhelix
ID: 11773947
Hi Arbert!

Once again, thanks for your help.
From what I can tell , the as400 always appends the data to the end of the table.  
There is no add date, change date, .. only invoice date =(

The information is approxmately 3 years worth of data .. approx 700,000 rows.
A complete import takes approx ~6 mins

I tried to
SELECT *
FROM DB01.TAITOR.TFITORDATA.ORIDPAB1
Where SCINV# NOT IN (SELECT SCINV# from ORIDPAB1)

Which to me, is selecting all invoice numbers that are inside the as/400 which are not inside the SQL Server.  This query took ~15 mins?

So I am not sure which is the best solution.  
0
 
LVL 34

Expert Comment

by:arbert
ID: 11774116
Well, to get the 6minutes down, you're probably better off to insert EVERY record into a local sql table and then apply your NOT EXISTS logic (don't use not in--query plan isn't quite as good).

If you can't guarantee the accuracy of the invoice number and invoice date, I really don't see a way around it.  Will the 700,000 grow much larger, or do they keep only a certain time period in this table?
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

Author Comment

by:2xhelix
ID: 11774613
700,000 will continue to grow over time.

To be quite honest, I am not really familiar with DTS and what it can provide.  
If I did a nightly import, that would require me to drop the table, and then import the table from as400?

since I believe the invoice history on the as/400 appends to the end of the table, and there are never any updates to any rows, is there some way I can just rowcount (as/400) - rowcount(sqlserver) .. then somehow start a cursor at that location and copy?

0
 
LVL 34

Accepted Solution

by:
arbert earned 250 total points
ID: 11774763
You could, but you CAN'T be guaranteed the order of the rows when you get them.  Only by adding an ORDER BY to your select statement are you guaranteed order--might not match the original AS400 table...

I don't think I would drop the entire table--transfer the entire as400 table into a sql server temp table (only transfer columns that you need) then, use the code (like you have above) to figure out what records don't exist and do an insert from the temp sql table....You'll find it's probably faster to transfer every row and put the criteria on SQL Server after the fact--linked servers aren't that efficient with criteria.
0
 

Author Comment

by:2xhelix
ID: 11783480
Great, I just put together everything, and started to import/update several tables last nite, and it is working perfectly.  And the execution times are acceptable as well.

Thank's for all your help .. don't know where I would be in this project without you =)
0

Featured Post

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL Server Designer 19 41
sql server computed columns 11 31
SQL Query Help Top 1 and Distinct? 6 26
SQL Count issue 24 16
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
I have a large data set and a SSIS package. How can I load this file in multi threading?
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Via a live example, show how to shrink a transaction log file down to a reasonable size.

773 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