August 16, 2013 at 7:57 am
Can anybody please help me on how to define the location of '-' in the comments?
For example, I have a comment like 'Work (210) 401-6838 for debtor(1) 'Guzman, Tarrasa' status changed from Good to Bad'.
I want to know which SQL function to use to locate the '-' inside the phone number. Here, it is 14th character in the comment. Then I can use the SUBSTRING ( expression ,start , length ) to take phone number out as 2104016838 format.
Thanks a lot!
yi
August 16, 2013 at 8:02 am
Take a look at PATINDEX
August 16, 2013 at 8:02 am
yi.wang 12733 (8/16/2013)
Can anybody please help me on how to define the location of '-' in the comments?For example, I have a comment like 'Work (210) 401-6838 for debtor(1) 'Guzman, Tarrasa' status changed from Good to Bad'.
I want to know which SQL function to use to locate the '-' inside the phone number. Here, it is 14th character in the comment. Then I can use the SUBSTRING ( expression ,start , length ) to take phone number out as 2104016838 format.
Thanks a lot!
yi
CHARINDEX will get you the location of a character.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
August 16, 2013 at 10:23 am
It works very well.
Thank you very much!
Yi
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply