Wednesday, 1 January 2014

Script Task For Pickup txt file From Folder


Step 1:
Create Two variables as shown in figure
One for Fullpath STRING
Another for Validate INT




Step 2:
In script task Editor Select valiadate variable as a Readonly variable and other for Readand write variable

"D:\\ExcelDestination\\ExcelWorkBook_"+ (DT_STR, 4, 1252) DATEPART("yy" , GETDATE())  +
RIGHT("0" + (DT_STR, 2, 1252) DATEPART("mm" , GETDATE()), 2)  + RIGHT("0" + (DT_STR, 2, 1252) DATEPART("dd" , GETDATE()), 2)+".xlsx"


Step 3:
Click on edit script then write like as shown in last image
Save then click OK

using System.IO;

public void Main()
{
// TODO: Add your code here
            String str = Dts.Variables["User::FullPath"].Value.ToString();
            if (File.Exists(str))
            {
                Dts.Variables["User::Validate"].Value = 1;
            }
            MessageBox.Show(str);
            MessageBox.Show(Dts.Variables["User::FullPath"].Value.ToString());


Dts.TaskResult = (int)ScriptResults.Success;
}



Step 4:
Go to properties of Fullpath by selecting that variable and click F4---->Expression--->Write expression shown in image Expression Builder--->Evaluate expression







Step 5:
Click on presidence constraint--> Evaluation and Constraint-->@validate ==1
in other line keep @validate==0

No comments:

Post a Comment

EMP, DEPT Sample script

/****** Object:  Table [dbo].[DEPT]    Script Date: 19-05-2016 06:58:37 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET A...