Professional Web Applications Themes

Looking for a specific character - Microsoft SQL / MS SQL Server

Hi I have to look for a specific character within a field and return its position. Is there a function to do this? eg. Field1 = "Toronto-ON": I need to find what position the "-" is in. Thanks....

  1. #1

    Default Looking for a specific character

    Hi I have to look for a specific character within a field and return its
    position. Is there a function to do this?

    eg.
    Field1 = "Toronto-ON": I need to find what position the "-" is in.

    Thanks.


    Sammy Guest

  2. #2

    Default Re: Looking for a specific character

    Have a look at this in BOL

    mk:MSITStore:C:\Program%20Files\Microsoft%20SQL%2 0Server\80\Tools\Books\acd
    ata.chm::/ac_8_con_11_481k.htm

    --

    ----------------------------
    Allan Mitchell (Microsoft SQL Server MVP)
    MCSE,MCDBA
    www.SQLDTS.com
    I support PASS - the definitive, global community
    for SQL Server professionals - http://www.sqlpass.org



    "Sammy the Bull" <com> wrote in message
    news:#phx.gbl... 


    Allan Guest

  3. #3

    Default Re: Looking for a specific character

    Well, I'm from Toronto-ON, so I guess it's my turn. ;-) Try:

    select charindex ('-', 'Toronto-ON')

    --
    Tom

    ---------------------------------------------------------------
    Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
    SQL Server MVP
    Columnist, SQL Server Professional
    Toronto, ON Canada
    www.pinnaclepublishing.com/sql


    "Sammy the Bull" <com> wrote in message news:#phx.gbl...
    Hi I have to look for a specific character within a field and return its
    position. Is there a function to do this?

    eg.
    Field1 = "Toronto-ON": I need to find what position the "-" is in.

    Thanks.



    Tom Guest

  4. #4

    Default Re: Looking for a specific character

    Sammy,

    DECLARE qa VARCHAR(20)
    SET qa='Toronto-ON'
    SELECT CHARINDEX('-',qa)

    --
    Dinesh.
    SQL Server FAQ at
    http://www.tkdinesh.com

    "Sammy the Bull" <com> wrote in message
    news:%phx.gbl... 


    Dinesh.T.K Guest

Similar Threads

  1. Extract Character By Character in PDF
    By s.r.krish@adobeforums.com in forum Adobe Acrobat SDK
    Replies: 14
    Last Post: March 14th, 12:14 PM
  2. How to navigate to a specific accordian panel INSIDE a specific tab navigator
    By face7hill in forum Macromedia Flex General Discussion
    Replies: 1
    Last Post: September 6th, 02:11 AM
  3. InDesign ME Character Problem! Character-Change by Printing or saving *.PS!
    By gree@adobeforums.com in forum Adobe Indesign Windows
    Replies: 48
    Last Post: May 25th, 02:07 PM
  4. REGEX: matching AFTER a specific character
    By Ben Crane in forum PERL Beginners
    Replies: 1
    Last Post: December 19th, 12:01 PM
  5. Sun-specific or SVR4 specific?
    By Victor in forum UNIX Programming
    Replies: 8
    Last Post: September 10th, 08:25 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139