Results 1 to 2 of 2

Thread: Question using patindex in SQL server

  1. #1
    Join Date
    May 2007
    Posts
    2

    Question using patindex in SQL server

    Alright, I am trying to write a query that will select a column.. then search through the column and return me the fields with no underscores in them.

    i.e we have fields that are like ABCD and ABCD_1. I want to basically return all of them up to the underscore.

    so i am trying to use a substring combined with patindex. Here is my statement for patindex. patindex('%_%', short_name)

    however, i cannot get patindex to ignore the fact that _ is a wildcard and treat it as character. Ive tried ('%[_]%', short_name) and ive tried ('%!_%', short_name) escape '!' and i just keep getting errors... If someone could help me out, that would be most appreciated. thank you.

  2. #2
    Join Date
    Dec 2004
    Posts
    502
    (see my reply in MS SQL2000 forum)

Posting Permissions

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