Function to return "remaining" of field after it finds a character in the field.

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

    Function to return "remaining" of field after it finds a character in the field.

    Hi,

    another problem I have is that have compounded fields in my sql table.

    Example

    product@custome r

    I need a simple function to return "customer", so it should return the value
    after "@", unfortunate "@" will sometimes be character number 6, sometimes
    character number 7 etc.

    regards
    Jorgen



  • Jorgen [DK/2600]

    #2
    Re: Function to return "remaining " of field after it finds a character in the field.

    Solutions was :

    set ANSI_NULLS ON

    set QUOTED_IDENTIFI ER ON

    GO

    CREATE FUNCTION [sapserviceaccou nt].[UNTRUNK2] (@inp as varchar(100))

    RETURNS varchar(20) AS

    BEGIN

    declare @out varchar(20);

    if LEN(@inp) 0

    begin

    set @out = right( @INP, (LEN(@INP)-CHARINDEX('@', @INP)))

    end

    else

    begin

    set @out = @inp;

    end

    return @out

    END

    "Jorgen [DK/2600]" <nyhedsgruppe_h ejhej_@gmail.co mwrote in message
    news:45daf1e7$0 $90272$14726298 @news.sunsite.d k...
    Hi,
    >
    another problem I have is that have compounded fields in my sql table.
    >
    Example
    >
    product@custome r
    >
    I need a simple function to return "customer", so it should return the
    value
    after "@", unfortunate "@" will sometimes be character number 6, sometimes
    character number 7 etc.
    >
    regards
    Jorgen
    >
    >
    >

    Comment

    Working...