dbTalk Databases Forums  

DTS Csv Files Import into SQL Server

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


Discuss DTS Csv Files Import into SQL Server in the microsoft.public.sqlserver.dts forum.



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

Default DTS Csv Files Import into SQL Server - 02-09-2005 , 08:50 PM






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

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

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

Here is the code i used to get first file from directory.
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
please reply me as soon as possible with code.

thanks

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

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

Default Re: DTS Csv Files Import into SQL Server - 02-10-2005 , 10:40 PM






Does it work


For Each fsoFile in fsoFolder.Files
sFilename = sFolder & fsoFile.Name
if right(sfilename,3)<> "lbp" then
Exit For
Next
end if

Next

--
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.