Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

define the location of '-' in the comments Expand / Collapse
Author
Message
Posted Friday, August 16, 2013 7:57 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, September 5, 2013 11:37 AM
Points: 2, Visits: 5
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
Post #1485217
Posted Friday, August 16, 2013 8:02 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Yesterday @ 10:16 AM
Points: 265, Visits: 321
Take a look at PATINDEX
Post #1485223
Posted Friday, August 16, 2013 8:02 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 11:26 AM
Points: 13,436, Visits: 12,299
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 Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1485224
Posted Friday, August 16, 2013 10:23 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, September 5, 2013 11:37 AM
Points: 2, Visits: 5
It works very well.
Thank you very much!

Yi
Post #1485301
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse