User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the MS SQL section within the Web Development category of DaniWeb, a massive community of 361,941 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,654 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MS SQL advertiser:
Views: 1115 | Replies: 2 | Solved
Reply
Join Date: Apr 2008
Posts: 37
Reputation: Yogesh Sharma is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
Yogesh Sharma Yogesh Sharma is offline Offline
Light Poster

Scalar Function

  #1  
Apr 8th, 2008
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.
Last edited by Yogesh Sharma : Apr 8th, 2008 at 4:36 pm.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jun 2007
Posts: 62
Reputation: manoshailu is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 4
manoshailu's Avatar
manoshailu manoshailu is offline Offline
Junior Poster in Training

Re: Scalar Function

  #2  
Apr 8th, 2008
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




Originally Posted by Yogesh Sharma View Post
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.
Reply With Quote  
Join Date: Apr 2008
Posts: 37
Reputation: Yogesh Sharma is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
Yogesh Sharma Yogesh Sharma is offline Offline
Light Poster

Re: Scalar Function

  #3  
Apr 9th, 2008
Thx I have Got it...
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb MS SQL Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the MS SQL Forum

All times are GMT -4. The time now is 11:32 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC