473,396 Members | 1,722 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Scalar Function

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.
Apr 8 '08 #1
3 3431
ck9663
2,878 Expert 2GB
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.

During creation, by default, you will own the function. Since sql server can handle multiple objects with the same name as long as it's owned by different owners, you have to specify the who owns the function you are calling. So during creation, owner is optional. In function call, it is required.

-- CK
Apr 9 '08 #2
Thx Ck,
dbo is d schems name.Its necessary to have dbo,cz we have the functions with the same name in different schemas.Me right or Wrong?

Can u plz tell me how to create Schema in SQL.
select dbo.myFunction() as 'Simple Number'
Apr 9 '08 #3
ck9663
2,878 Expert 2GB
I would assume you're referring to functions, not schema.

Read the full syntax here

--CK
Apr 9 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Mountain Man | last post by:
Hi, I have an array derived from a set of radio buttons that I want to break down into a single variable for use with a database. How can I do this? $gender is the array, and I want $gender2 to...
7
by: Steve Jorgensen | last post by:
Hi all, I've been using scalar functions as a way to perform some complex data transformation operations, and I've noticed that scalar functions reaaaaalllllyyyy sloooowwwwww thiiiiiings...
7
by: roger | last post by:
I'm having difficulties invoking a user defined table function, when passing to it a parameter that is the result of another user defined function. My functions are defined like so: drop...
2
by: Martin MacRobert | last post by:
Hi, I'm trying to make a specialisation of a template function, so that the second parameter accepts scalar types only (int,double,float etc.). How can I do this without writing an explicit...
0
by: Simon Riggs | last post by:
I'm trying to create some User Defined Functions, which act as scalar functions. I can successfully create a UDF like this: drop function arraylistset; CREATE FUNCTION ArrayListSet (ArrayList...
4
by: al havrilla | last post by:
hi all what does the phrase: "scalar deleting destructor" mean? i'm getting this in a debug error message using c++ 7.1 thanks Al
5
by: Eli | last post by:
Hi, I want to check whether a value is a scalar. A scalar can be: - None (null) - string - number (integer, float) - boolean How can I validate a value is one of these types? I care about...
5
by: deepdata | last post by:
Hi, I am trying to create a function which returns a scalar data. My function tries to insert a row in a table as well. /** CREATE function getManufacturerId ( manufacturer VARCHAR(128) )
0
by: uymqlp502 | last post by:
Version 1.4 of my scalar class is available at http://RussP.us/scalar.htm No major changes. I have corrected the "repr" function to make it more useful, and I have added a "unit_type" function...
5
by: Arepi | last post by:
Hi! 1, How can I quevery the stringlenght of a scalar (like in C the function : strlen() ) 2,How can I quevery the sizeof a scalar (like in C the operator: sizeof ) Thanks!
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.