Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Server 2000 DTS Package Active X Help

Status
Not open for further replies.

S1002

Programmer
Aug 28, 2007
14
US
I have a Package which can process any number of files and after processing each file it Archives the Processed
file in the Archive Folder.
I cannot reprocess/Import the same file again(in case by mistake)
to avoid this i need to put a check before each run to check the archive folder with the input folder if i have the Same file again(File with same name)

Can any one help me with the Active X Script
 
I had the similar situation, what I was doing before copying the files to destination I'm checking the filesize and last modified if it changes then replace else do nothing.
I don't know how much this will help you, but give a try.

Function Main()
script3
Main = DTSTaskExecResult_Success
End Function

sub script3()
fromDir = DTSGlobalVariables("gvSrcPath").Value 'Source Path
toDir = DTSGlobalVariables("gvDestPath").Value 'Destination Path

start = Now()
replaceSize = 0
copySize = 0
deleteSize = 0
noChangeSize = 0

If fso.FolderExists(fromDir) And fso.FolderExists(toDir) Then
Call ReplicateDirectory(fromDir, toDir)
Else
logFile.WriteLine("Error ...................... : No directory found")
End If
End sub

Sub ReplicateDirectory(source, target)
Dim t, objShell, CmdLine, rc
Dim WshShell
Set WshShell = CreateObject("WScript.Shell")

Set fso = CreateObject("Scripting.FileSystemObject")
Set targetDir = fso.GetFolder(target)
Set sourceDir = fso.GetFolder(source)
Set targetDirFileList = targetDir.Files
Set sourceDirFileList = sourceDir.Files
Set targetDirFolderList = targetDir.SubFolders
Set sourceDirFolderList = sourceDir.SubFolders

'Overwriting files at Destination Directory
For Each targetFile in targetDirFileList
If fso.FileExists(source & "\" & targetFile.Name) Then
Set sourceFile = fso.GetFile(source & "\" & targetFile.Name)
If targetFile.DateLastModified <> sourceFile.DateLastModified Then
targetFilePath = targetDir.Path & "\" & targetFile.Name
replaceSize = replaceSize + sourceFile.Size
sourceFile.Copy targetFilePath
sourceFile.Delete
Else
noChangeSize = noChangeSize + sourceFile.Size
End If
Else
noChangeSize = noChangeSize + targetFile.Size
End If
Next

For Each sourceFile in sourceDirFileList
If Not fso.FileExists(target & "\" & sourceFile.Name) Then
copySize = copySize + sourceFile.Size
sourceFile.Copy targetDir.Path & "\" & sourceFile.Name
sourceFile.Delete
End If
Next

For Each sourceFolder in sourceDirFolderList
If Not fso.FolderExists(targetDir & "\" & sourceFolder.Name) Then
copySize = copySize + sourceFolder.Size
sourceFolder.Copy(targetDir & "\" & sourceFolder.Name)
Else
Call ReplicateDirectory(sourceFolder.Path, targetDir & "\" & sourceFolder.Name)
End If
Next

'logFile.Close()
finish = Now()

End Sub


Good Luck,
Gragi
 
Thank you Gragi,
the script is very useful
may be ican check all the files in the source folder
with all the files inthe destination folder in 'FOR LOOP'.
and if any is matched exist else continue.
Iam using your script for my other packages that needed
the above logic.
thans once again



 
Hi there,
need Help on this

I have a DTS package which creates two excel files with filedate extension.
(i get file date from inputfile ).

i used active X for creating the XLS files (i did not select the Excel connection icon
from the task bar)

the problem is if i have to rerun the file again , during the run time it
will promt me to overwrite the file and if i don`t it will fail.

I want the file tobe overwritten without any prompts and run the package succesfully.

Thanks
 
Hi everybody,
what is the eqivalent datatype in T-SQL
for the datatype double (8)

i have a field that stores money with datatype decimal(13,2) which i will have to export to a >DAt file as
double(8).
any help on this

thanks
 
Hello everyOne,

I have Dts packages on SQL Server 2000 Devloper edition
I can't Schedule the packages that load the data from files on the windows server
or generates reports onthe server but i can schedule the package if it
has to do something with in the SQL server databases.

can any one help me on this .

thank You
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top