12.6.09

User defined function error in SQL Server

Today while trying to create a function, am trying to execute the function created. Am getting an error showing "'Venkat_fun2' is not a recognized built-in function name."

Strange behavior of SQL Server. I need to raise this issue with Microsoft techies. Let me check it and blog the same with the reason.

create function Venkat_fun2(@a int)
returns int
as begin
RETURN
(select id from venkat where id=@a)
end

select Venkat_fun2(1)

Thanks and Regards,
Venkatesan Prabu .J

3 comments:

  1. Venkatesan Prabu .JJune 12, 2009 at 6:33 PM

    Found the problem.


    We need to add the schemaname.FunctionName to execute it.

    alter function Venkat_fun2(@a int)
    returns int
    as begin
    RETURN
    (select id from venkat where id=@a)
    end

    select dbo.Venkat_fun2(1)


    The above query will work.

    Thanks and Regards,
    Venkatesan Prabu .J

    ReplyDelete
  2. Hi Venkat
    I am T-SQL Developer and am working for past one and half years in SQL. I need to complete certification can you provide me some tips to complete the certifications. It will help for my preparation.

    Regards
    Amarnath

    ReplyDelete
  3. Try this
    create function Venkat_fun2(@a int)
    returns int
    as begin
    RETURN
    (select id from venkat where id=@a)
    end
    GO

    select dbo.Venkat_fun2(1)

    sqlblogcasts.com/blogs/madhivanan

    ReplyDelete