SQL Server Developer Center > SQL Server Forums > SQL Server Integration Services > Help with Derived column function (newbie question)
Ask a questionAsk a question
 

AnswerHelp with Derived column function (newbie question)

  • Sunday, November 08, 2009 4:05 AMSteve_Fox Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi All
    I have a column (first 3 rows shown below) & I need to extract out the part that falls between the $ (inclusive)  and the /. So for Row 1,  I want to extract $10, for Row 2 I want $100 and row 3 I want $29. These then need to be put into a new column. I assume this can be done using the derived column transformation. As a newbie - I am looking for the simplest way to do this.

    Row 1 = 3G Browsing Pack $10/150MB
    Row 2 = 3G850 HSDPA DTPK $100/150MB
    Row 3 = 3G850 HSDPA DTPK $29/300MB
    etc etc

    Many thanks

    Steve

Answers

  • Sunday, November 08, 2009 4:28 AMNitesh Rai Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Try this expression inside a derived column:
    SUBSTRING(ID,FINDSTRING(ID,"$",1),FINDSTRING(ID,"/",1) - FINDSTRING(ID,"$",1))

    ID is the column name.
    Nitesh Rai- Please mark the post as answered if it answers your question
    • Marked As Answer bySteve_Fox Sunday, November 08, 2009 7:35 PM
    •  

All Replies

  • Sunday, November 08, 2009 4:28 AMNitesh Rai Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Try this expression inside a derived column:
    SUBSTRING(ID,FINDSTRING(ID,"$",1),FINDSTRING(ID,"/",1) - FINDSTRING(ID,"$",1))

    ID is the column name.
    Nitesh Rai- Please mark the post as answered if it answers your question
    • Marked As Answer bySteve_Fox Sunday, November 08, 2009 7:35 PM
    •  
  • Sunday, November 08, 2009 7:37 PMSteve_Fox Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Many thanks Nitesh. The expression did the trick.

    Cheers

    Steve