Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Use DTS to write data from SQL to Dbase

Status
Not open for further replies.

christer102

IS-IT--Management
Aug 15, 2007
17
US
Trying to insert data from SQL to Dbase using DTS. The problem is that I have it just "cloning" the data, only inserting data where the record already exists (so I end up having two record in the Dbase table), and it is ignoring any new records that exists in the SQL table. Obviously I need an insert statement, I have tried the datadriven query, which is telling me no query spefication returned by transform status. Can anyone point me in the right direction how to do this? I need to have insert new records from SQL, and then secondly update any existing records from SQL.

 
First run your update query for everything that already exists in destination (use an inner join).

Then, to insert only the new records:

Code:
select a.*
from SourceTable a
left join DestinationTable b
on a.PrimaryKey = b.PrimaryKey
and a.OtherIdentifier = b.OtherIdentifier
where b.PrimaryKey is null

This is easy if you have a linked server set up (don't know if this is even possible for dBase) but if you don't, you will have to bring everything across into a staging table and then perform your updates and inserts from this staging table.

Hope this helps,

Alex

[small]----signature below----[/small]
I don't do any programming whatsoever

Ignorance of certain subjects is a great part of wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top