Execute Function RRS feed

  • Question

  • hi all,

    say for eg i have a function and proc named as fun_sample and proc_sample respectivley.

    why do we specify "dbo.fun_sample" for executing the function, whereas only "proc_sample" is enought for executing the proc?

    Monday, February 26, 2007 8:50 AM

All replies

  • For scalar function:

    select dbo.fun_sample()


    declare @v int

    set @v = dbo.fun_sample()

    For table-value function:

    select * from dbo.fun_sample()

    Monday, February 26, 2007 9:57 AM
  • sorry, u have not got my question.

    my doubt is why we are specifying the ownername for executing a function?

    Monday, February 26, 2007 10:25 AM
  • "dbo." isn't owner name, it's schema. If you use function without schema name, SQL Server think that it's system function. For stored procedures "sp_" prefix is a reason to resolving as system stored procedure.
    Monday, February 26, 2007 10:47 AM
  • firstly its a schema name or owner name, depending on the version of sql server being used...owner for 2000 and schema for 2005

    for the main question...why dbo. for a function... i guess its just a syntax thing ...and it does saves time for the server... so maybe i'll use it evn if its not mandatory.... use it for sps as well....

    Monday, February 26, 2007 1:37 PM