Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 import text file

Author  Topic 

helixpoint
Constraint Violating Yak Guru

291 Posts

Posted - 2005-08-01 : 11:05:44
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

22859 Posts

Posted - 2005-08-01 : 12:07:11
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
   

- Advertisement -