questions about string value

  • Hi, All:

       I am having a problem with string value. Here is the case. I have two tables. Their primary keys are a little different.

    For example:

       table1:  LALA LULU [33q][v0.1]

       table2:  LALA LULU [33q] [v0.1]

    There is a space in front of the version value which is [v0.1] in table2. Thus, when I join the two tables, they cannot be joined. What I did was using "charindex" function to find the position of "[". However, it gets the position of the first [ appeared. How can I get the second [ in this case? Or do you have any solution to make the string values become the same??  Please help~~~ Thank you!

  • Charindex has start_location argument.

    In your case the statement would be

    select charindex('[', col, charindex('[', col)+1) from table2

    assume col is the name of the column.

     

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply