About Me

My photo
Programming is my passion

Friday, April 8, 2011

File System Task

I am new in SSIS although I have good experience with DTS. In the below article I am explaining how to move the file from location to another location using SSIS.

1) We will create to two location one is Source and another is destination with full right



2) Open BIDS.


3) Right click on “Control Flow” click on “Variables’” option

4) Variables windows will be open add below variable using “” add (below screen shot)

a) Destination:-Specify the destination path

b) FileExtension:- Specify the extension of file which move

c) FileName:- This variable value will be filled by “ForEachLoop” Container

d) SourcePath:- Specify the source path

e) SourcePathWithFile:- This variable store concatenation of Source path and FileName


5) Add “foreach loop container” into Control Flow window double click on it “ForeachLoop” editor will be open


a) Select “Collection” option select Enumerator type “Foreach File Enumerator
b) Expand “Expression” option on “Collection” window click on button “Property
Expression Builder”
will be open



c) Select “Directory” from property drawdown list Click on “Expression” button
“Expression builder” window will be open specify “sourcePath” variable as mentioned below
screen



d) Click on ok button expression values will be shown on “Property Expression editor”. Same action perform for Name


E) Click “Variable mappings” option on “ForEachLoop” Editor. select FileName variable from variable dropdown list click ok

F) We will use “SourcePathWithFile” as expression variable for that select “SourcePathWithFile” Variable
press F4 button change below property

a) EvaluateAsExpression:- set it true

b) Expression:- create a expression which will concatenate SourcePath and FileName(Shown below screen)

c) Namesapce :-It is optional I have change value from User to UserExp so I can differentiate it from other variables



ForeachLoop task configuration completed

6) Drag “File System Task” from toolbox inside “ForEachloop” container

7) Double click on “File System Task” the editor will be open where we will configure below

properties

a) IsDestinationPathVariable: Set is true

b) DestinationVariable:- Select Destination variable

c) Operation:- Select “Move File”

d) IsSourcePathVariable:-Set is true

e) SourceVariable:- Select Source variable

Click ok

8) Go to Source folder create some file which will be moved

9) Go BIDS and run package using F5


10) File will be moved to destination folder and source folder will be empty




No comments:

Post a Comment