concanate two fields using DTS

Posted on 2006-06-05
Last Modified: 2013-11-30
hi guys, i have a small problem, I am doing a dts from an excel spreadsheet to a sql server table. the fields are the area code and the phone number column. I need to concanate these two columns into one column in my sql server table. that part is done; however i also need to format this numbers (right now coming out as 3055625889 instead of (305) 562-5889, I have to do this from the dts point of view, can someone help me??? this is what i have so far..

this is what i have so far, but keep getting the error message Duplicate column name ' Account Manager Phone '

this is my code:

Function Main()
      IF ISNULL(DTSSource("ACCT MGR AREA CODE").Value) _
      OR _
      DTSDestination("Account Manager Phone") = ""
      DTSDestination("Account Manager Phone") = _
      FormatPhoneNumber(DTSSource("ACCT MGR AREA CODE").Value & _
      DTSSource("ACCT.MANAGER PHONE").Value)
      END IF
      Main = DTSTransformStat_OK
      End Function
Function FormatPhoneNumber(strPhone)
      ' strPhone parameter is the area code and phone number concatenation
      Dim strNew
      strNew = "(" & Left(strPhone,3) & ") " & Mid(strPhone,4,3) & "-" & Mid(strPhone,7,4)
      FormatPhoneNumber = strNew
      Main = DTSTransformStat_OK
      End Function


Question by:printmedia
    LVL 13

    Expert Comment

    That looks correct to me? What happens if you don't use the FormatPhoneNumber function?

    Author Comment

    same error
    LVL 13

    Expert Comment

    Check your transform, the destination tab and make sure Account Manager Phone isn't in there twice. That's the ony thing that I can see is possible.

    Author Comment

    thanks, but eventhough now i made it work all the fields come out as null , any ideas why?
    LVL 30

    Expert Comment

    I would suggest you load the data in as normal then run an Update quwery (from DTS) to format the numbers.
    LVL 13

    Accepted Solution

    Because one of the fields is null? IF you're concatenating two fields and one is NULL both become null. If you want to concatenate them you will have to use an ISNULL function to convert it to an empty string or zero depending on if it is character or numeric.

    nmcdermaid is right, it is usually easier to bring the data in then manipulate it with SQL. But that's a decision for you.
    LVL 75

    Expert Comment

    by:Anthony Perkins
    >>IF you're concatenating two fields and one is NULL both become null. <<
    You may want to double check that using an ActiveX script.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Performance is the key factor for any successful data integration project, knowing the type of transformation that you’re using is the first step on optimizing the SSIS flow performance, by utilizing the correct transformation or the design alternat…
    Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
    Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
    Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now