Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SSIS and Import/Export (2005)
 get file modified date

Author  Topic 

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2008-01-10 : 05:29:48
Hi,

the ssis package loops through a folder using a foreach loop container and imports the data inside each .csv file into the database.

Now I would like to add the functionality to first check the modified date of the .csv file. If it is NOT today's date then the package should fail or go to error.

Any thoughts how to do this please?

Thanks

nr
SQLTeam MVY

12543 Posts

Posted - 2008-01-10 : 05:55:13
Move the files to an archive folder after import then you will know that they are new files. Add a datestamp to the file when moving it to the archive.
Is better if the file name has a datestamp when it's put in the folder - if not I would run something else to rename the files. That will allow you to see if there is a problem as files will accumulate in the import folder.


==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2008-01-10 : 06:16:14
The first thing before the import is to check the date of the file.
Is there a way is SSIS?
Thanks
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-01-10 : 06:42:51
Write a script task to retrieve modified date from file and then check this to current date and raise error if not equal.
Go to Top of Page

rohitkumar
Constraint Violating Yak Guru

472 Posts

Posted - 2008-01-10 : 10:04:47
some clue on the activex scripting to be done

http://www.sqldts.com/238.aspx
Go to Top of Page

rgombina
Constraint Violating Yak Guru

319 Posts

Posted - 2008-01-16 : 08:43:19
Script Task test...

Public Sub Main()
Dim modDate As DateTime = File.GetLastWriteTime(Dts.Variables("strFileName").Value.ToString)
Dim nowDate As DateTime = DateTime.Now
Dim compDate As Boolean = False

If modDate < nowDate = True Then
MsgBox("Yes, Modified Date is less than today's date!" & vbCrLf & "modDate = " & modDate & vbCrLf & "nowDate = " & nowDate)
Else
MsgBox("No, Modified Date is the same as today's date!" & vbCrLf & "modDate = " & modDate & vbCrLf & "nowDate = " & nowDate)
End If

Dts.TaskResult = Dts.Results.Success
End Sub
Go to Top of Page
   

- Advertisement -