SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 import text file
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

helixpoint
Constraint Violating Yak Guru

279 Posts

Posted - 08/01/2005 :  11:05:44  Show Profile  Reply with Quote
I am new to DTS. In fact this is my first. Is there a demo how to parse threw a tab delimited file and either update the records or insert records

Dave

Kristen
Test

United Kingdom
22415 Posts

Posted - 08/01/2005 :  12:07:11  Show Profile  Reply with Quote
I don't reckon DTS will do an "Upsert" out of the box.

You'll probably have to use DTS to suck the data into a staging table, and then from there do:

UPDATE U
SET   U.Col1 = S.Col1,
...
FROM  MyStagingTable S
      JOIN MyTable U
          ON U.MyPK = S.MyPK

INSERT INTO MyTable
(
    Col1, Col2, ...
)
SELECT Col1, Col2, ...
FROM MyStagingTable S
      LEFT OUTER JOIN MyTable U
          ON U.MyPK = S.MyPK
WHERE U.MyPK IS NULL

If "MyTable" has an IDENTITY column, and you want to preserve the Identity column from the imported data, there is some additional fancy-SQL required.

Kristen
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000