September 8, 2010 at 12:59 pm
I need to open a text file and look for the word "Error" before trying to upload it.
I am using a Script Task, I see there is Find and Replace but is there just find?
When if it finds "Error" I want the package to stop.
Thanks
September 8, 2010 at 3:58 pm
You could use OPENROWSET BULK to achieve this
IF (SELECT CHARINDEX('Error', BulkColumn) FROM OPENROWSET (BULK 'C:\YourFile.txt', SINGLE_CLOB) AS Z) > 0
SELECT 'ERROR IN FILE'
September 8, 2010 at 10:16 pm
Approach 1: This could be done very gracefully using a Script Task/Component
Approach 2: Some kind of lookup...i'm not much sure of Approach 2
Raunak J
September 9, 2010 at 4:40 am
Dim strfile As String = "C:\File.txt"
Dim fs As New IO.FileStream(strfile, FileMode.Open, FileAccess.ReadWrite)
Dim read As StreamReader
read = New StreamReader(fs)
read.BaseStream.Seek(0, SeekOrigin.Begin)
Dim rd As String = Nothing
Dim text As String = Nothing
While (read.Peek() > -1)
text = Trim(read.ReadToEnd())
If text.Contains("Error") Then
Dts.Variables("v_StopthePackage").Value = True
Else
MsgBox("HOOOOOOOOOOOOOO")
End If
End While
Use the above sample code and change it as per your req. In the Constraint call the Stop variable to stop the Package.
This may Help!
September 9, 2010 at 8:31 am
I forgot to add that 3 different files I need to check, they all start with DirectSat, can I search a path with a wildcard?
Thx.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply