Remember to generate a new package id when using a package template or a copy:
Till Next Time
A collection of SSIS stuff from 101 till 404. I just put the things here I run into....
Till Next Timedeclare @date datetimeset
@date = getdate()
--get first day of month
select dateadd(m, datediff(m, 0, @date), 0)
--get last day of month
select dateadd(m, datediff(m, 0, dateadd(m, 1, @date)), -1)
'This function gets all the user defined variables from a SSIS package
'(except ado Objects) and put them in a flatfile
'This flatfile can be
used to transfer the variables to a LOG file
'in the database
'20081030
John Minkjan
Function Main()
Dim oVal
Dim isSystem, varType,
varName, varValue
Dim str, FileName, filesys, filetxt
Const
ForReading = 1, ForWriting = 2, ForAppending = 8
Set filesys =
CreateObject("Scripting.FileSystemObject")
FileName = "c:\varfile_"&
DTSGlobalVariables("System::PackageName").Value &".txt"
Set filetxt
= filesys.OpenTextFile(FileName, ForWriting, True)
'Put in a header
filetxt.WriteLine("varName;varType;varValue")
For each oVal in
DTSGlobalVariables
isSystem = oVal.SystemVariable
varType =
oVal.DataType
varName = oVal.QualifiedName
varValue = oVal.Value
if not isSystem then
if varType <> 13 then '(Ado Objects)
if varValue = null or varValue = "" then
varValue = "NULL"
end
if
filetxt.WriteLine(Cstr(varName) &";" & Cstr(varType) &
";" & Cstr(varValue))
end if
end if
Next
filetxt.Close
Main = DTSTaskExecResult_Success
End
Function
Public Sub Main()
Dim strBackupdir As String
Dim strBackupSubDir As
String
Dim strProjectName As String
Dim intDaysBack As Integer
strBackupdir = "..\Backup\"
strProjectName = "project name"
intDaysBack = 7
For Each strSubDirFound As String In Directory.GetDirectories(CStr(strBackupdir))If Mid$(strSubDirFound, Len(strBackupdir) + 1, Len(strProjectName)) = strProjectName Then
For Each FileFound As String In Directory.GetFiles(strSubDirFound, "*.bak")
If File.GetCreationTime(FileFound) < Now().AddDays(-intDaysBack) Then
File.Delete(FileFound)
End If
Next
End
If
Next
Dts.TaskResult = Dts.Results.Success
End Sub