Home     |     Java    |     Php General    |     Oracle Database    |     Oracle Server  

MS Dynamics CRM 3.0

  •  Setting up and Configuring Microsoft Dynamics CRM 3.0
  •  Managing Security and Information Access
  •  Entity Customization: Concepts and Attributes
  •  Entity Customization: Forms and Views
  •  Entity Customization: Relationships, Custom Entities, and Site Map
  •  Reporting and Analysis
  •  Workflow
  •  Server-Side SDK
  •  Client-Side SDK
  •  Integration with External Applications
  • Cervo Technologies
    The Right Source to Outsource

    Sharepoint Portal Server KB

    Microsoft CRM Info

    WPF Interview Questions

    SilverLight Interview Qs

    Asp.Net 2.0 Interview Qs

    Asp.NET 1.1 FAQs

    Oracle Interview Questions

    SAP Interview Questions

    Oracle Database

    Simple SQL query help - String functions


    I need a select query that selects the first, last and middle name of
    employees without hyphens, apostrophes, blanks, periods, suffixes
    (Jr.) or prefix (Dr.). My current query looks something like this:

    Select Fname, Lname, Mname
    from employee
    where <condition>

    Any help will be appreciated !

    Thanks
    Thangam

    Tangz wrote:
    > I need a select query that selects the first, last and middle name of
    > employees without hyphens, apostrophes, blanks, periods, suffixes
    > (Jr.) or prefix (Dr.). My current query looks something like this:

    > Select Fname, Lname, Mname
    > from employee
    > where <condition>

    > Any help will be appreciated !

    > Thanks
    > Thangam

    It is impossible to help you based on what you have asked. Where
    would one find the hyphens, apostrophes, blanks, periods, suffixes,
    prefixes, etc.?

    Give us three to five sample rows and the desired outcome.

    Explain what is wrong with your current statement.

    And include your version to 3 decimal places.
    --
    Daniel A. Morgan
    University of Washington
    damor@x.washington.edu
    (replace x with u to respond)
    Puget Sound Oracle Users Group
    www.psoug.org

    -----------------------------------------------Reply-----------------------------------------------

    On 24 Apr 2007 12:34:35 -0700, Tangz <thangam.m@gmail.com> wrote:

    >I need a select query that selects the first, last and middle name of
    >employees without hyphens, apostrophes, blanks, periods, suffixes
    >(Jr.) or prefix (Dr.).

    'Parsing' strings will never ever undo the ramifications of bad
    database design.
    The number of prefixes you'll need to deal with is endless.
    Fix your tables instead of fighting symptoms.

    --
    Sybrand Bakker
    Senior Oracle DBA

    -----------------------------------------------Reply-----------------------------------------------

    On 24 Apr., 21:34, Tangz <thangam.m@gmail.com> wrote:

    > I need a select query that selects the first, last and middle name of
    > employees without hyphens, apostrophes, blanks, periods, suffixes
    > (Jr.) or prefix (Dr.). My current query looks something like this:

    > Select Fname, Lname, Mname
    > from employee
    > where <condition>

    On first glance I would say that this goes beyond simple string
    manipulation. Hence you might consider writing a stored function and
    call that:

      Select StripNameFuzz(Fname), StripNameFuzz(Lname),
    StripNameFuzz(Mname)
      from employee
      where <condition>

    StripNameFuzz would get the dirty string and return the cleaned one. I
    think I would scan it char by char using substr to be able to handle
    complex situations.

    But maybe this suffices in your case:

      replace(Lname,'Dr. ', ' ') to remove 'Dr.'
      replace(Lname,' Jr.', ' ') to remove 'Jr.'
      translate(LName,'''" .', 'aea') to remove and replace special
    chars

    You see there is not much logic in there. 'Dr.' must be followed by
    blank to be recognized for instance.

    Combining the string functions it becomes something like this:

      select translate(replace(replace(Lname,'Dr. ', ' '),' Jr.', '
    '),'''" .', 'aea') ...

    -----------------------------------------------Reply-----------------------------------------------

    Thorsten Kettner wrote:
    >   select translate(replace(replace(Lname,'Dr. ', ' '),' Jr.', '
    > '),'''" .', 'aea') ...

    Assuming it doesn't contain "Dr" without the period, or "MD PhD" or M.D.
    Ph.D" and a near infinite supply of other variants. Often the job is
    hopeless unless the table is redesigned to guarantee integrity.
    --
    Daniel A. Morgan
    University of Washington
    damor@x.washington.edu
    (replace x with u to respond)
    Puget Sound Oracle Users Group
    www.psoug.org
    Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc