Flat files
Hi, i have 44 files. 1) i want check the file size , if size = 0,i want send the mail and i won't process the that file and process the remaining files how can i do it
October 20th, 2010 6:15pm

Do a for-each loop to cycle through the files, then do the file size check in a Script Task, this task can assign a value to a package level variable and based on it you send the email or process it, you may use precedence constraints to fire the email or not. Help for every step: Looping through files: http://www.sqlis.com/post/Looping-over-files-with-the-Foreach-Loop.aspx Script Task: http://blogs.techrepublic.com.com/programming-and-development/?p=666 Precedence Constrains: http://blogs.msdn.com/b/mattm/archive/2006/10/30/using-expression-based-constraints.aspx?wa=wsignin1.0 Arthur My Blog
Free Windows Admin Tool Kit Click here and download it now
October 20th, 2010 6:22pm

Hello, Note: I am assuming all 44 files have same metadata, if Not then Go with Scrip task Declare a variable VarRowCnt int type 1--Use foreach loop to loop through the files 2--Inside loop Drag Data Flow , in Data Flow drag Flat File source, RowCount after that and Destination at the end. In Row Count Transformation use VarRowCnt 3--Connect your Data Flow task to Send Email, use Precedence constraint and use Expression @[User::VarRowCnt]==0 , Test and OK. in Send Mail task, use Expressions , in Expression , MessageSource, your expression would be something like this "Would not process "+@[User::FileName]+" file as has No records" OR You can use Script task, read the records and send the mail by using Script task itself Or get the size of file in Script task and then pass value back to some variable to send email by using Send email task. helpful links: foreach loop http://www.sqlis.com/post/Looping-over-files-with-the-Foreach-Loop.aspx Precedence Constraint http://www.sqlservercentral.com/articles/Video/64798/ http://ssisblog.replicationanswers.com/2007/11/11/fun-with-precedence-constraints.aspx how to write expressions in precedence constaint http://blogs.msdn.com/b/mattm/archive/2006/10/30/using-expression-based-constraints.aspx Thanks
October 20th, 2010 6:28pm

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

Other recent topics Other recent topics