FIRST EXAMPLE--CREATE FUNCTION dbo.myFunction()
RETURNS INT
AS
BEGIN
DECLARE @myInt INT
SET @myInt = 1
RETURN @myInt
END

select dbo.myFunction() as 'Simple Number'

This Function is not returning any value,Error is coming
Cannot find either column "dbo" or the user-defined function or aggregate "dbo.myFunction", or the name is ambiguous.


SECOND EXAMPLE--

create function dbo.add1(@num1 Int,@num2 Int)
Returns INT
as
Begin
Return(@num1+@num2)
End

select dbo.add1(10,20) as result

Above function is working fine,but dbo is optional IF I write the above Function without dbo
create function add1(@num1 Int,@num2 Int)
Returns INT
as
Begin
Return(@num1+@num2)
End

select add1(10,20) as result
Then the Function is Contructed successfully , But when I call the function usimg Select statement
Error is there--
'add1' is not a recognized built-in function name.

Plz reply whether its necessary to write owner name to prevent errors.

hi,
First Example is wrkg well. Then why you geting the errors Check well. And then for functions owner name is not an optional one, You must define the function name with owner name to execute it.


Shailaja:)

FIRST EXAMPLE--CREATE FUNCTION dbo.myFunction()
RETURNS INT
AS
BEGIN
DECLARE @myInt INT
SET @myInt = 1
RETURN @myInt
END

select dbo.myFunction() as 'Simple Number'

This Function is not returning any value,Error is coming
Cannot find either column "dbo" or the user-defined function or aggregate "dbo.myFunction", or the name is ambiguous.


SECOND EXAMPLE--

create function dbo.add1(@num1 Int,@num2 Int)
Returns INT
as
Begin
Return(@num1+@num2)
End

select dbo.add1(10,20) as result

Above function is working fine,but dbo is optional IF I write the above Function without dbo
create function add1(@num1 Int,@num2 Int)
Returns INT
as
Begin
Return(@num1+@num2)
End

select add1(10,20) as result
Then the Function is Contructed successfully , But when I call the function usimg Select statement
Error is there--
'add1' is not a recognized built-in function name.

Plz reply whether its necessary to write owner name to prevent errors.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.