Simple function for returning a character based on search criteria..

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jorgen [DK/2600]

    Simple function for returning a character based on search criteria..

    Hi,

    how do I do a simple formula, which will search a field for special
    characters and return a value.

    If it finds "%" - it returns 1
    else
    If it finds "?" it returns 2

    end

    If this is the incorrect newsgroups, please direct me to the correct one

    regards Jorgen



  • Jorgen [DK/2600]

    #2
    Re: Simple function for returning a character based on search criteria..

    Ah.. this one is actually a bit more complex.

    My problem is that in a amount field I have both % and Quantity mixed
    together. So the formula should check the "format" column for the amount
    field, if the format columns contains "%" it return the value - if not, i
    writes zero in my expression.

    Logical ?

    Regards
    Jorgen
    "Jorgen [DK/2600]" <nyhedsgruppe_h ejhej_@gmail.co mwrote in message
    news:45daf1ca$0 $90275$14726298 @news.sunsite.d k...
    Hi,
    >
    how do I do a simple formula, which will search a field for special
    characters and return a value.
    >
    If it finds "%" - it returns 1
    else
    If it finds "?" it returns 2
    >
    end
    >
    If this is the incorrect newsgroups, please direct me to the correct one
    >
    regards Jorgen
    >
    >
    >

    Comment

    • Erland Sommarskog

      #3
      Re: Simple function for returning a character based on search criteria..

      Jorgen [DK/2600] (nyhedsgruppe_h ejhej_@gmail.co m) writes:
      Ah.. this one is actually a bit more complex.
      >
      My problem is that in a amount field I have both % and Quantity mixed
      together. So the formula should check the "format" column for the amount
      field, if the format columns contains "%" it return the value - if not, i
      writes zero in my expression.
      SELECT CASE format WHEN '%' THEN amount ELSE 0 END

      I don't know if this fits your bill. But if it does not, please post:

      o CREATE TABLE statement for your table(s)
      o INSERT statements with sample data.
      o The desired result given the sample.

      This helps to clarify what you are looking for, and makes it easy to copy
      and paste to develop a tested solution.


      --
      Erland Sommarskog, SQL Server MVP, esquel@sommarsk og.se

      Books Online for SQL Server 2005 at

      Books Online for SQL Server 2000 at

      Comment

      Working...