scalar user defined functions

  • i created this SCALAR function

    CREATE FUNCTION [dbo].[ufnNickTblPersonOrganizationSuperTypeID](@PersonOrganizationSuperTypeName VARCHAR(10))

    RETURNS int

    AS

    ---------------------------------------------------------------------------------------------

    -- History of changes:

    ---------------------------------------------------------------------------------------------------

    BEGIN

    declare @PersonOrganizationSuperTypeID int

    Select

    @PersonOrganizationSuperTypeID = PersonOrganizationSuperTypeID

    from NickTblPersonOrganizationSuperType(NOLOCK)

    Where PersonOrganizationSuperTypeName = @PersonOrganizationSuperTypeName

    RETURN @PersonOrganizationSuperTypeID

    END

    and then i tried to execute it like this;

    select * FROM

    dbo.ufnNickTblPersonOrganizationSuperTypeID

    ('MORIN')

    but the server throws this error:

    Msg 208, Level 16, State 3, Line 1

    Invalid object name 'dbo.ufnNickTblPersonOrganizationSuperTypeID'.

    could someone tell me what am doing wrong executing it

  • klineandking (5/24/2010)


    i created this SCALAR function

    CREATE FUNCTION [dbo].[ufnNickTblPersonOrganizationSuperTypeID](@PersonOrganizationSuperTypeName VARCHAR(10))

    RETURNS int

    AS

    ---------------------------------------------------------------------------------------------

    -- History of changes:

    ---------------------------------------------------------------------------------------------------

    BEGIN

    declare @PersonOrganizationSuperTypeID int

    Select

    @PersonOrganizationSuperTypeID = PersonOrganizationSuperTypeID

    from NickTblPersonOrganizationSuperType(NOLOCK)

    Where PersonOrganizationSuperTypeName = @PersonOrganizationSuperTypeName

    RETURN @PersonOrganizationSuperTypeID

    END

    and then i tried to execute it like this;

    select * FROM

    dbo.ufnNickTblPersonOrganizationSuperTypeID

    ('MORIN')

    but the server throws this error:

    Msg 208, Level 16, State 3, Line 1

    Invalid object name 'dbo.ufnNickTblPersonOrganizationSuperTypeID'.

    could someone tell me what am doing wrong executing it

    You are trying to use it like a TVF. Try select dbo.yourfunction('value');

  • Thanks it worked i appreciate your help

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply