|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Wednesday, March 27, 2013 8:55 AM
Points: 289,
Visits: 683
|
|
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
|
|
|
|
|
SSCarpal Tunnel
       
Group: General Forum Members
Last Login: Yesterday @ 11:01 PM
Points: 4,319,
Visits: 9,659
|
|
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:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
If you are asking for help and your post does not contain a question, you should expect responses which do not contain any answers. Put a question mark in there somewhere - it's not rocket science.
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Wednesday, March 27, 2013 8:55 AM
Points: 289,
Visits: 683
|
|
| Tried that and it still executed the flat file destination
|
|
|
|
|
SSCarpal Tunnel
       
Group: General Forum Members
Last Login: Yesterday @ 11:01 PM
Points: 4,319,
Visits: 9,659
|
|
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:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
If you are asking for help and your post does not contain a question, you should expect responses which do not contain any answers. Put a question mark in there somewhere - it's not rocket science.
|
|
|
|