Wednesday, March 7, 2012

Import and Overwrite DB from Text File

First off, I am not a DBA, not even remotely close. Anywho, I have been given the task of figuring out how to import from a comma delimited text file into 2 columns of an existing database. The task is as follows:

- A daily text file is created by a Unix DB and placed on a folder local to the SQL Server.
- I am to take this file and import into an existing MS SQL2005 DB that has 3 columns.
- AccountID, AccountName, DateRecordCreated
- The imported data has to overwrite all existing SQL DB data.
- This is to run automated on a daily schedule.

Being a SysAdmin, this sounds super simple to do but I have wasted 2 full days in trying to figure out how to make this happen using SSIS. All I want to know is if I am in the right track in focusing on SSIS for a solution. Any additional How To's would be greatly appreciated. BTW, the text file looks something like this...

AccountID,AccountName
A123456,Joe Smith, M.D.
A234567,John H. Dude,M.D.

Thanx much
Recipe as follows:

Control flow:
1 - Execute SQL Task to issue a SQL statement: "truncate table account_table"
1 - Data flow to load the CSV file to the data base

Data flow:
1 - Flat File Source
1 - OLE DB Destination set to use "Table or view - fast load"

Then setup a SQL Server Agent job to execute the SSIS package.

No comments:

Post a Comment