dbTalk Databases Forums  

Import Multiple Files using dts

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Import Multiple Files using dts in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
chinna jambu via SQLMonster.com
 
Posts: n/a

Default Import Multiple Files using dts - 02-09-2005 , 04:27 PM






Hello, I want to create a DTS, it must import multiple csv files from the
same Folder into two different tables. The files are "LDP_" + 3 letter
code( like LDP_CCC,LDP_XXX) and "ADP_" +3 letter code (Like ADP_AKC,ADP_MEM)
.. I know how to load it to the database, I am using looping method.I
created two dts Packages one for LDP_*.csv and another for ADP_*.csv.

Somebody can help me how to load only LDP_*.csv files to LDPtable and
ADP_*.files to ADPtable.


Function Main()

Dim sFolder
Dim fso
Dim fsoFolder
Dim fsoFile
Dim sFilename
sFolder = DTSGlobalVariables("ImportFolder")
set fso = CreateObject("Scripting.FileSystemObject")
set fsoFolder = fso.GetFolder(sFolder)
For Each fsoFile in fsoFolder.Files
sFilename = sFolder & fsoFile.Name
Exit For
Next

Dim oPKG
Dim oConnection
Dim stdEnterLoop

set oPKG = DTSGlobalVariables.Parent
set oConnection = oPKG.Connections ("Text File (Source)")
oConnection.DataSource = sFilename



Main = DTSTaskExecResult_Success
End Function

Thanks a lot!!!
Reply to this message

--
Message posted via http://www.sqlmonster.com

Reply With Quote
  #2  
Old   
Darren Green
 
Posts: n/a

Default Re: Import Multiple Files using dts - 02-09-2005 , 05:39 PM






In message <30052946556d4458a972ca34eb0ca766 (AT) SQLMonster (DOT) com>, chinna
jambu via SQLMonster.com <forum (AT) SQLMonster (DOT) com> writes
Quote:
Hello, I want to create a DTS, it must import multiple csv files from the
same Folder into two different tables. The files are "LDP_" + 3 letter
code( like LDP_CCC,LDP_XXX) and "ADP_" +3 letter code (Like ADP_AKC,ADP_MEM)
. I know how to load it to the database, I am using looping method.I
created two dts Packages one for LDP_*.csv and another for ADP_*.csv.

Somebody can help me how to load only LDP_*.csv files to LDPtable and
ADP_*.files to ADPtable.


After updating your connection, add some code to determine the table
name based on the name of the file found. Then set the SourceObjectName
of your DataPump task.

N.B. This will only work if the structure of the files/tables is the
same.


Changing the DataPump Source and Destination Tables
(http://www.sqldts.com/default.aspx?213)

--
Darren Green (SQL Server MVP)
DTS - http://www.sqldts.com

PASS - the definitive, global community for SQL Server professionals
http://www.sqlpass.org



Reply With Quote
  #3  
Old   
chinna jambu via SQLMonster.com
 
Posts: n/a

Default Re: Import Multiple Files using dts - 02-09-2005 , 06:25 PM



thank you for quick response.

I have 10 files with different names in c:\mydirectory\.
I created global variable "ImportFolder" which has value "c:\mydirectory\"

files are LDP_aaa.csv,Ldp_bbb.csv,LDP_ccc.csv and
ADP_aaa.csv,ADp_bbb.csv ADp_cc.csv.

My question here is only import LDP_*.csv to sql server table and ignore
ADP_*.csv files from the directory.

please reply me as soon as possible with code.

thanks

--
Message posted via http://www.sqlmonster.com

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.