English 中文(简体)
SSIS Package failing with New structure of Flatfile
原标题:

SSIS package is just importing from txt file to sql database. when we made the package were using old file and its executing fine.the old source file got (10 columns) the new source file got 15 columns. when the source file changed its failing. [Flat File Source [1]] Error: Data conversion failed. The data conversion for column "Column 10" returned status value 4 and status text "Text was truncated or one or more characters had no match in the target code page.". Variation in the columns made a problem how to resolve this in better way? If both old and new format files need to be processed with same Package.

Thanks

最佳回答

If I understand your question correctly, you have a file (same file name I assume) that either has the old or new file format and fails because your flat file source has the old (10 column) data file schema only? If this is the case, I would create a boolean variable and call it something like isOldFormat. I would then use a script task in your control flow to determine if it has 10 or 15 columns. The pseudocode would be something like this:

1)Open flat file 2) Count the columns based on your delimiter 3) Condition Statment:

If columns.Count = 10 isOldFormat = True Else If columns.Count = 15 isOldFormat = False Else throw error

Then I would create another data flow that would have the new file format schema (now basically you have two data flows-one with your old file format and one with the new one).

After this step, you would then drag precedence constraint from your script task to the newly created data flow and one to the old data flow. By double clicking on your predence constraint, you would then set the evaluator operation property to Expression and type in the Expression box @isOldFormat == true for the constraint going to the data flow that contains the old flat file source and @isOldFormat == false for the other data flow. What this will do will only execute one or the other data flow based on variable that is set in your script task.

Hope this helps.

问题回答

暂无回答




相关问题
SQL Server database is not visible

I have installed ASP.NET application with database on our server. ASP.NET application created database using connection string below. The problem is that I do not see database in SQL Server Management ...

Most efficient way to store number 11.111 in SQL Server

What datatype is the most efficient to store a number such as 11.111. The numbers will have up 2 digits before the point and up to three after. Currently the column is a bigint , I am guessing that ...

表格和数据表

是否需要在提瓜表之后更新表格统计数据,还是自动更新?

Inconsistent Generate Change Script

I add a column of type tinyint and being set to not allow nulls in a table and generate the change scripts. The table has data in it at this time. The script has code that creates a temp table and ...

Performance of Sql subqueriesfunctions

I am currently working on a particularly complex use-case. Simplifying below :) First, a client record has a many-to-one relationship with a collection of services, that is, a single client may have ...

selecting one value out of an xml column

I have a particularly troublesome xml column to query data from. The schema is fixed by the Quebec Ministry of Revenue so "it is what it is" The important part of the query looks like this: with ...

Selecting records during recursive stored procedure

I ve got a content management system that contains a hierarchical structure of categories, with sub-categories subject to different ordering options at each level. Currently, that s retrieved by a (...

热门标签