Friday, February 17, 2012

Execute Function

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?

For scalar function:

select dbo.fun_sample()

or

declare @.v int

set @.v = dbo.fun_sample()

For table-value function:

select * from dbo.fun_sample()

|||sorry, u have not got my question.

my doubt is why we are specifying the ownername for executing a function?|||"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.|||

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....

No comments:

Post a Comment