Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Prevent flat file from being written (SSIS 2008r2)


Prevent flat file from being written (SSIS 2008r2)

Author
Message
Resender
Resender
SSC-Addicted
SSC-Addicted (473 reputation)SSC-Addicted (473 reputation)SSC-Addicted (473 reputation)SSC-Addicted (473 reputation)SSC-Addicted (473 reputation)SSC-Addicted (473 reputation)SSC-Addicted (473 reputation)SSC-Addicted (473 reputation)

Group: General Forum Members
Points: 473 Visits: 1564
SO In the project I'm working I'm importing csv files from a dynamic map to a database.
As an extra feauture I made it so that all the lines that are faulty get written into a csv file and all the good lines into another.
So that when correcting not all the lines have to be redone or people have to spend hours finding the correct line.

So I originally did this in SSIS 2012 now I have to remake it in 2008r2,in 2012 if a flat file doesn't receive inputs it isn't written but it seems in 2008r2 it does.
I can't go check the files based on size cause the column headers are already in the file.
So I thought about using a rowcount into a variable and based on that execute a create script, I can create the file however only the last row is written and also how do I access the variables.

The code section that should generate the lines is below & is based off
http://agilebi.com/jwelch/2007/06/03/multi-file-output-destination-script-component/


'This method is called once for every row that passes through the component from Input0.
'
'Example of reading a value from a column in the the row:
' zipCode = Row.ZipCode
'
'Example of writing a value to a column in the row:
' Row.ZipCode = zipCode
Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer)
Dim column As IDTSInputColumn100

' If Not Row.SERVER = previousValue Then
If Not fileWriter Is Nothing Then
fileWriter.Close()
End If
fileWriter = New StreamWriter(targetFolder + fileName + fileCount.ToString() + fileExt, False)
'fileCount += 1
'previousValue = Row.SERVER
'End If

With fileWriter
.Write(Row.SERVER + delimiter)
.Write(Row.STATUS.ToString() + delimiter)
.Write(Row.OU.ToString() + delimiter)
.Write(Row.OS.ToString + delimiter)
.Write(Row.SP.ToString + delimiter)
.Write(Row.VERSION.ToString() + delimiter)
.Write(Row.INSERVEROU.ToString + delimiter)
.Write(Row.DATEADDED.ToString + delimiter)
.Write(Row.DATECHANGED.ToString() + delimiter)
.WriteLine()
End With

If Not Row.SERVER = previousValue Then
fileWriter.WriteLine()
previousValue = Row.SERVER
End If

End Sub


Phil Parkin
Phil Parkin
SSCrazy Eights
SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)

Group: General Forum Members
Points: 8310 Visits: 19457
Maybe you could come at this from another angle.

Why not put a rowcount transformation underneath the script component and then delete the file in the control flow if [rowcountvariable] == 0?


Help us to help you. For better, quicker and more-focused answers to your questions, consider following the advice in this link.

If the answer to your question can be found with a brief Google search, please perform the search yourself, rather than expecting one of the SSC members to do it for you.

Please surround any code or links you post with the appropriate IFCode formatting tags. It helps readability a lot.
Resender
Resender
SSC-Addicted
SSC-Addicted (473 reputation)SSC-Addicted (473 reputation)SSC-Addicted (473 reputation)SSC-Addicted (473 reputation)SSC-Addicted (473 reputation)SSC-Addicted (473 reputation)SSC-Addicted (473 reputation)SSC-Addicted (473 reputation)

Group: General Forum Members
Points: 473 Visits: 1564
Tried that and it still executed the flat file destination
Phil Parkin
Phil Parkin
SSCrazy Eights
SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)

Group: General Forum Members
Points: 8310 Visits: 19457
Resender (2/20/2013)
Tried that and it still executed the flat file destination


I did not say it wouldn't.

My suggestion is to perform the deletion as part of the control flow - after the completion of the data flow and after the file has been created.


Help us to help you. For better, quicker and more-focused answers to your questions, consider following the advice in this link.

If the answer to your question can be found with a brief Google search, please perform the search yourself, rather than expecting one of the SSC members to do it for you.

Please surround any code or links you post with the appropriate IFCode formatting tags. It helps readability a lot.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search