Solved

DTS Package - Check Source Text Files for Proper Record Count Before Importing Data

Posted on 2003-10-30
1
421 Views
Last Modified: 2007-12-19
I need to import 3 text source files of 10 rows each.   I've created the DTS package to perform these imports however now I want to add additional logic into the package.  I want to check the source files to see if they are of the proper record count before performing following steps.  

Note: The source text file names are named 300Data.txt, 400Data.txt and 500Data.txt with the first 3 char corresponding to the PK in tblMaster (destination).

1. test for a proper record count.  
2. if record count = 10 then
            delete recs for PK 300 in tblMaster
            run the DTS transformation to bring new PK 300 records in
    else
            skip the import for this file - it's better to have the old compete records than new
            incomplete data.
    end if

What is the best way to build this logic into a DTS package?  Also can I access the DTS object.ConnectionProperties("Data Source") property from within a package to simply repoint it to another text file to perform the next import?  

I'm looking for the best book on SQL Server DTS with lots of good examples.  Any suggestions would be greatly appreciated.


0
Comment
Question by:petrmica
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 8

Accepted Solution

by:
Dishan Fernando earned 250 total points
ID: 9649365
Create a DTS with these steps

1. Import All the txt file data into temp tables ..
2. Take a One temp Table and do Count records.
 if it's bigger than 10
 then Run your DTS using following Code using "Execute SQL Task"

IF EXIST ( SELECT 1 FROM #T1 HAVING COUNT(*) = 10)
BEGIN
  -- Run DTS
EXECUTE master..xp_cmdshell 'dtsrun /S <ServerName> /U <UserName> /P <Password> /N <DtsName> /M <DtsPassword>'
END

3 Do this for your other Temp Tables

0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Viewers will learn how the fundamental information of how to create a table.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

738 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