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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Import Text File with condition

Status
Not open for further replies.

spiff2002

IS-IT--Management
Jan 31, 2003
40
We get a file on a daily, weekly basis. I need to import that file into our MS SQL server 2000 database. The file that comes in has a period column which (for instance: '2005-02')
The file has sales for the same period only so all items in that column will be the same.
I need to read the file using DTS. These are the conditions:
I should be able to read the period before uploading the file to the table. If there is already Data for period '2005-02' then I need to delete any data for that period in the table to avoid duplicate data since the file is cumulative. After that check then I need to append the data in the file to the remaining data in the table.

Should I upload to a temp table and then move the data to the final table? Is there a way to do it directly from the file to the final table???


 
I would recommend that you upload to a Temp table and then use a SP (Stored Procedure) to perform the deletion of existing data if necessary and finally perform the insert.
-Karl

[red] Cursors, triggers, user-defined functions and dynamic SQL are an axis of evil![/red]
[green]Life's uncertain...eat dessert first...www.deerfieldbakery.com[/green]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top