.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

SSIS Script Componet to change Flat File LF to CR LF

Posted By:      Posted Date: October 18, 2010    Points: 0   Category :Sql Server


I have a corrupt Flat File and I need to write a SSIS Script Component to Replace LF to CR LF in my flat file.

Any idea how to do it?



View Complete Post

More Related Resource Links

Import a flat file with combined data into separate SQL tables using SSIS

I have a flat text file (comma delimited) that is essentially multiple files, each with its own format, combined into one file. The file is coming from an external software vendor so unfortunately we don't have much choice but to work with what we are receiving. Here is an example of what the file could look like: Customer Data CustID,FName,LName,PhNum,Email 12345,John,Smith,,jsmith@gmail.com 12346,Jane,Doe,8001111111,jdoe@hotmail.com Customer Plan CustID,PlanType,PlanName,PlanStart 12345,0,Plan1,01/01/2010 12345,2,PlanVis,01/01/2010 12346,3,PlanLf,04/01/2010 12346,0,Plan1,01/01/2010 Customer Payment CustID,LastPayment,Amount 12345,09/01/2010,100.00 12346,05/01/2010,50.00 There is an empty line between each 'section' of data. I adapted a VB script I found online that can take the incoming file and save off each section as its own file so that each one can be separately imported, but this seems inefficient. I'm really new to SSIS in general, but it seems like it shouldn't be that difficult to take the data, split it where there is an empty line, and then import each section into the appropriate SQL table. Any ideas would be most welcome. Thanks!  

SSIS package - change Web reference's addres from Configuration file?

Greetings. The SSIS packages provide very nice options to configure them from an XML file, which allows to change credentials, database names etc w/o editing the package. This lets me, say, transfer package from one server to another or from test to production w/o any hassle - just changing the xml. Problem is, i need to acces a web service in my package, and built-in SSIS web service task is useless and just SUCKS. It fails to work even with miscrosoft's own sharepoint web service. So, i have to use scripting task. And scripting task uses "web reference" to access web services, which in turn gives no way to change it's url.  So, if i want to test and then move to production, i'll have to edit my package to change the web reference url from "testserver:5123/mywebservice" to "productionserver:81/webservices/mywebservice". And then change it again to test it again. Etc. Is there a solution to this? A way to programmatically change web reference's url from inside scripting task?

SSIS flat file performance improvement


I have 10 text files which are on average of 6  GB in size. Out of those 10, 4 files average up to 10 GB in size.

We have 10 SSIS packages which loads those text files onto 2 staging tables. Each 5 of them loads 1 table.

Inside the package, its only a flat file source, data conversion for all columns from source, and write into the destination table.

And this process takes around 5 hours to complete. the size of 2 tables after the load completes is 60 M and 40 M each.


The other thing which I have observed is all the packages are scheduled through one schedule and the schedule  have 10 diff sql server jobs( for 10 packages). Does it have an impact on the processing time ,as all these jobs will be

How capture bad records from "Flat File Source" in SSIS


The flat file is having 10 columns so used 9 delimitor. Few records in the Flat file is having more than 10 columns. I need to redirect in to some error table and rest valid records needs to be loaded in target. Pls help.

SSIS: Error in the package when the data in the flat file source is modified


Hi All,

I have a package which loads data from a flat file source to an OLEDB destination, which is executed successfully and data is loaded perfectly.

But later when the data in the flat file source is modified i.e. if an extra column gets added to the text file, the package is throwing an error because it is unable to detect the extra added column.

How can i avoid this error??? I need my package to execute successfully ignoring the changes(added columns) happened in the flat file source.

Please provide me wth your suggestions and solutions....

Thanks in Advance!!

Accessing a flat file/folder via SSIS that is out of my domain


I'm trying to copy a file to a desitnation in an SSIS package that requires a username and password in order to connect. I am doing this in VB Script task and have tried this:


Dim ServerShare, UserName, Password As String
Dim NetworkObject, FSO As Object
ServerShare = \\someserver\sharename$

Prevent SSIS from creating an empty flat file


I created a SSIS to export to a flat file (from a SQL command : a stored proc).

I don't wan't my SSIS to create an empty file if there is no data.


How can I achieve this ?





SSIS Flat File Destination


I have a requirement to output some large data sets as flat files.

They have specified the file format and I have no issues with all but one thing. They want the data files to end with "the standard EOF character that is used in Linux". When I look at the file I produce with SSIS in a text editor that shows the HEX values the last thing I see in the file is the newlline (0A) chactare for the last line. How can I get it to insert this EOF character they want?

Get latest file name using SSIS script task: Error while execution


Hi  , I am trying to get the latest file name to process files in SSIS using vb.net code . I did set the varible in the For each loop container and assigned the variable in my file connection. I have been receiving this error msg.: Please help me out.

Error: 0x2 at Get File Name: The script threw an exception: The element cannot be found in a collection. This error happens when you try to retrieve an element from a collection on a container during execution of the package and the element is not there.

Task failed: Get File Name

Warning: 0x80019002 at Foreach Loop Container: SSIS Warning Code DTS_W_MAXIMUMERRORCOUNTREACHED. The Execution method succeeded, but the number of errors raised (1) reached the maximum allowed (1); resulting in failure. This occurs when the number of errors reaches the number specified in MaximumErrorCount. Change the MaximumErrorCount or fix the errors.

SSIS package "testpackage.dtsx" finished: Failure.


SSIS Dynamic Flat Files (Can't get ConnectionString property to dynamically change)


Hi all,

I am trying to do what many have already tried.  I wish SSIS was made more user friendly in this perspective, but I am trying to have SSIS read a folder directory, and get all the files based on a condition that I've specified.

I was following this link:  http://consultingblogs.emc.com/jamiethomson/archive/2005/05/30/SSIS_3A00_-Enumerating-files-in-a-Foreach-loop.aspx

So I have a For-Each loop, and within it, I have my Data Flow Task which includes a Flat File Source Connection.  The problem is, how do I pass that information to the connection string?  I can see the connection string in the XML file, but for some reason, I cannot access the property "ConnectionString".  The first property I see when I go to the expressions editor is "DelayValidation."  Furthermore, I've seen documents online where it there is a "connectionString" property for the Flat File Source Connection.  Well, I see no such property.

Any help with specific steps would be greatly appreciated.  Also, once I've figured that part out, I need to be able to move the files to another location after they have been put in the SQL Server DB.  This was much easier in coding a vb.net application.

SSIS Codepage Err on Flat File Inport


I'm trying to import a flat file into a table. nothing complex I thought but I get this err and i'm baffled -

The code page on column manager_id (70) is 1252 and is required to be 65001.

What's going on here and how do I fix this?

Can I Describe a Flat File Source to Save SSIS User Some Effort


I'm a complete SSIS beginner.  I suspect the answer to my question is out there I just don't know enough to construct the search that would find it.

I'm writing a program to generate fixed width format text files from proprietary databases for use as Flat File Sources in SSIS packages.  I know I can provide a header row containing column names.  But I have a lot more information about the file (obviously!).  I know how many columns there are, what the width of each column is, what the type of each column is, etc.

Is there some way I can record the information I have so that the SSIS user consuming my file doesn't have to input all that information through the Import and Export Wizard? 

For example, if I were generating these files for use with the BCP utility I could create a Format File to describe the structure of each field in my data file.  Is there some similar capability in SSIS or do the consumers of my data files have to input InputColumnWidth, Data Type etc. through the Advanced editor dialog box?

SSIS 2008 R2 Flat File Destination Producing Duplicates


I am writing to a flat file destination in a 2008 SSIS package. 99.99% of it works correctly. However, I get one duplicate record in the destination file.


Here is the basic flow of the package:

 1. Read two ISO-8859-1 encoded files and encode their text to UTF8 in memory

 2. Combine the two files together in memory and load them into a lookup cache

 3. Read another source file from disk

 4. Match an ID column

SSIS - Script Task Error - Could not load file or assembly


I have script task that has references added to it but still giving me above error? How should i resolve this situation?


Problem in Date Format While Exporting To Excel Destination From Flat File Source In SSIS



I have a flat file(.csv) which contains data(strings incuding date in yyyy-mm-dd format).This i am using in Flat File Source and want to export those data to an Excel Destination.Before exporting to Excel Destination i have created a Derived Column component where i am using an express to get day,month,year part and creating a date sting in dd/mm/yyyy format then conveting it to DT_DATE datatype and then exporting to Excel Component.But while exporting to Excel this date format is getting changed to mm/dd/yyyy format.

The expression i used in derived column is

(DT_DATE)(SUBSTRING(date,9,2) + "/" + SUBSTRING(date,6,2) + "/" + SUBSTRING(date,1,4))

where date is a column from Flat File Source.

Even I changed the Locale to English(United Kingdom) in Flat File Connection Manager for the above .csv file.But still it didnt work.

I searched a lot in google and failed to get any solution on this.

Can anyone help me in solving this issue ?

File Upload to an .ashx Script.


Hoping that someone can help me with this. I've been tearing my hair out for days looking for sources and coming up with nothing.

Basically, the scenario is this: I'm working on a project whereby an iPhone will make an HTTP-POST call to an .ashx file on my site. The POST will consist of some fields and a file.

I'm having difficulty - read that as no luck what-so-ever - in finding the form fields or the file when I look at the HTTPContext object in the debug mode of Visual Studio. And if I look at HTTPContext.Request.Files.Count (where I would expect to find a file count) the value is always zero!!

Please help, very confused by this!



How to change this code to allow more file uploads

I have a page currently setup to upload 1 image at a time, it uploaded the image, then creates a thumbnail for that image in the same directory. Client needs / wants to be able to upload a few more images at the same time. So i would like to see if i can use the existing code that works, but setup to upload a few more images and process them all to create the thumbnails. I currently have a page that allows them to upload 5 images at a time and that works fine, but its just simple uploading the images, nothing else is happening at that moment. Here is the code i am working with: protected void UploadBtn_Click(Object sender, EventArgs e) { String pth = Server.MapPath("~/gallery/homebirth/images/"); String UploadedFile = MyFile.PostedFile.FileName; int ExtractPos = UploadedFile.LastIndexOf("/") + 1; //to retrieve only Filename from the complete path String UploadedFileName = UploadedFile.Substring(ExtractPos, UploadedFile.Length - ExtractPos); // Display information about posted file. Div is invisible by default FileName.InnerHtml = UploadedFileName; MyContentType.InnerHtml = MyFile.PostedFile.ContentType; ContentLength.InnerHtml = MyFile.PostedFile.ContentLength.ToString(); //div is made visible FileDetails.Visible = true; // Save up
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend