I am trying to develop a package in SSIS 2005 and part of my process is to check if a file on the network is empty or not. If it is not empty, I need to pass a status of successful, otherwise, I need to pass a status of unsuccessful. I think I need a script task, but am not sure how to go about it. Any help is appreciated.
相关问题
- keeping one connection to DB or opening closing pe
- SQL Server Import Wizard doesn't support impor
- Quickest method for matching nested XML data again
- Bulk insert from excel to sql for selective fields
- What are IN and OUT parameter in SQL Server
相关文章
- SSIS solution on GIT?
- Convert column to string in SQL Select
- Why not “Invalid column name XYZ” error in subquer
- Create @TableVariable based on an existing databas
- How can I manually fail a package in Integration S
- Convert bit type to Yes or No by query Sql Server
- See complete tooltip error message for Data Flow S
- Save content of Email body in outlook to a file
Create a connection to the flat file in the Connection Managers panel. Under the Control flow tab, add a Data Flow Task.
Double click the Data flow task and add a Flat File Source and Row Count item.
In the Row Count properties, create a RowCount variable.
In the Control Flow tab, create control flow connections based on the result of the @RowCount.
Yes, a Script task will do the job here. Add a using System.IO statement to the top of the script, then something along the lines of the following in the Main method will check the contents of the file.
Edit: VB.Net version for 2005...
There are two ways to do it:
If file empty means size = 0 you can create a Script Task to do the check: http://msdn.microsoft.com/en-us/library/ms345166.aspx
Otherwise, if file empty means no rows (flat file) you can use the a Row Count transformation after you reads the file. You can set a variable from the Row Count using the 'VariableName' property in Row Count editor and use it as a status.
Add a simple Script Task with the following code(C#) should do the trick:
This option will run a lot quicker than the accepted answer as it doesn't need to read the whole file, if you are cycling through a folder of files and some of them are large, in my case ~800mb, the accepted answer would take ages to run, this solution runs in seconds.