[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

10/06/2009 at 03:55AM PDT, ID: 24788328
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

6.4

Converting Varchar text fields into Dates and Numerics

Asked by simon_kirk in SSIS

Hi.
We are trying to import fixed width text files into our sql 2005 db's using SSIS, but during the import require some conversion on fields.  This worked ok with SQL2000 DTS as we were able to utilise the vbScript to do the conversions, but our migration to SQL 2005 and SSIS is giving us a headache, as we cannot find a way to replicate what we currently are doing.

The conversions we require are:

a) Date columns - format in the text file is ddmmyyyy e.g. 23062001 which is fine in SSIS.  However empty/blank dates are either represented by 8 spaces or 00000000

b) Numeric columns - format is 9.2 so £123.45 is 000012345.  This is ok in SSIS, but needs to be divided by 100 to get the decimal places correct

The Options we've identified so far are:

Option 1 - derived column for every column requiring conversion
As per this post http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/Q_23939174.html we can create a function, but it needs to be repeated for every column, and we have a lot of columns and a lot of files to import.  This could potentially work if we had some sort of reusable component for use within the package and other packages.

Option 2 - change the source data .
Not an option as due to legacy system constraints we are unable to do this.

Option 3 - staging table.  
Not an effective option as due to the type of text file being imported, we already operate 2 staging table imports

Option 4 - script component
See code snippet for what we've tested so far.  This works, but again we don't know how to re-use it within and for other packages.

Option 5 - use varchar fields in db and convert post import
While it can be done, this is getting around the problem and also creates more work and other issues.

Thx
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer)
 
If Row.Column8 = "00000000" Or Row.Column8_IsNull = True Then
 
Row.ChangetoDate_IsNull = True
 
Exit Sub
 
Else
 
Row.ChangetoDate = CDate(Right(Row.Column8, 2) + "/" + Mid(Row.Column8, 5, 2) + "/" + Mid(Row.Column8, 1, 4))
 
End If
 
End Sub
[+][-]10/07/09 08:19 AM, ID: 25516491

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: SSIS
Sign Up Now!
Solution Provided By: simon_kirk
Participating Experts: 0
Solution Grade: A
 
 
 
Loading Advertisement...
20090824-EE-VQP-74 - Hierarchy / EE_QW_EXPERT_20070906