0

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.

2
Contributors
2
Replies
4
Views
9 Years
Discussion Span
Last Post by Yogesh Sharma
0

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.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.