script code in ssis to run the the report bi weekly
#region Namespaces using System; using System.Data; using Microsoft.SqlServer.Dts.Runtime; using System.Windows.Forms; using System.Globalization; #endregion namespace ST_ae0a9c4483b244eb90bb4c915c8f1bce { [Microsoft.SqlServer.Dts.Tasks.ScriptTask.SSISScriptTaskEntryPointAttribute] public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase { public void Main() { DateTime todaysDate = DateTime.Now; DateTimeFormatInfo dfi = DateTimeFormatInfo.CurrentInfo; Calendar cal = dfi.Calendar; //return success on odd numbered weeks if (cal.GetWeekOfYear(todaysDate, dfi.CalendarWeekRule,dfi.FirstDayOfWeek) % 2 == 1) Dts.TaskResult = (int)ScriptResults.Success; else Dts.TaskResult = (int)ScriptResults.Failure; } #region ScriptResults declaration /// <summary> /// This enum provides a convenient shorthand within the scope of this class for setting the /// result of the script. /// /// This code was generated automatically. /// </summary> enum ScriptResults { Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success, Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure }; #endregion } } Chuck Pedretti | Magenic North Region | magenic.com
June 15th, 2012 12:37pm

Hi Guru's, I am working on an SSIS package which has the sript task as the first component. The purpose of the script task is to run the report if its the day to run otherwise shouldn't run. The package needs to run bi weekly i.e every alternating thursdays. Can you help me to build the code for the bi weekly? Roy
Free Windows Admin Tool Kit Click here and download it now
June 15th, 2012 12:38pm

I would just use GetWeekOfYearNumber in the script and then decide if you are going to execute on even or odd week numbers http://msdn.microsoft.com/en-us/library/system.globalization.calendar.getweekofyear(v=vs.100).aspxChuck Pedretti | Magenic North Region | magenic.com
June 15th, 2012 12:43pm

#region Namespaces using System; using System.Data; using Microsoft.SqlServer.Dts.Runtime; using System.Windows.Forms; using System.Globalization; #endregion namespace ST_ae0a9c4483b244eb90bb4c915c8f1bce { [Microsoft.SqlServer.Dts.Tasks.ScriptTask.SSISScriptTaskEntryPointAttribute] public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase { public void Main() { DateTime todaysDate = DateTime.Now; DateTimeFormatInfo dfi = DateTimeFormatInfo.CurrentInfo; Calendar cal = dfi.Calendar; //return success on odd numbered weeks if (cal.GetWeekOfYear(todaysDate, dfi.CalendarWeekRule,dfi.FirstDayOfWeek) % 2 == 1) Dts.TaskResult = (int)ScriptResults.Success; else Dts.TaskResult = (int)ScriptResults.Failure; } #region ScriptResults declaration /// <summary> /// This enum provides a convenient shorthand within the scope of this class for setting the /// result of the script. /// /// This code was generated automatically. /// </summary> enum ScriptResults { Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success, Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure }; #endregion } } Chuck Pedretti | Magenic North Region | magenic.com
Free Windows Admin Tool Kit Click here and download it now
June 15th, 2012 12:51pm

Thank You Chuck. It was helpful
June 15th, 2012 1:10pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics