Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2007
    Posts
    4

    Unanswered: Alpha Prefix - Can it be done in SQL?

    Good Morning Db forum.


    I am working on a query that I need to pull all fields that contain 3 alpha characters. for example BCB001, MCR001, CHP001 and so forth.

    Is there a SQL alpha wildcard that I could use to pull all records that have the three alpha chars?

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    where patindex('%[a-z][a-z][a-z]%',daColumn) > 0

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Jun 2007
    Posts
    4
    Awesome thank you. Now would that be the same for say numbers/digits?

    where patindex like [0-9][0-9][a-z]% if i wanted to return 145A or something along those lines?

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    something along those lines -- you should test it yourself
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

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