SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 How can i do this?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

zakeer
Starting Member

India
20 Posts

Posted - 03/18/2008 :  08:39:02  Show Profile  Reply with Quote
Can we use a system defined funtion inside a userdefined function?

I am facing prob ...try to sort it out

create function fncube(@i int)
returns int
as
begin
declare @output int
set @output = power(@i,3)
returns @output
end


when i executing this, it is not getting executed.

help me

Thanks & Regards
Zakeer

elancaster
A very urgent SQL Yakette

United Kingdom
1208 Posts

Posted - 03/18/2008 :  08:42:45  Show Profile  Reply with Quote
quote:

create function fncube(@i int)
returns int
as
begin
declare @output int
set @output = power(@i,3)
returns @output
end



should be...

create function fncube(@i int)
returns int
as
begin
declare @output int
set @output = power(@i,3)
return @output
end


Em
Go to Top of Page

elancaster
A very urgent SQL Yakette

United Kingdom
1208 Posts

Posted - 03/18/2008 :  08:43:44  Show Profile  Reply with Quote
or just...

create function fncube(@i int)
returns int
as
begin
return power(@i,3)
end



Em
Go to Top of Page

PABluesMan
Starting Member

26 Posts

Posted - 03/24/2008 :  15:39:47  Show Profile  Reply with Quote
My guess is that you aren't calling the function with the schema prefix. So, instead of calling:

SELECT fncube (3)

... you need to call ...

SELECT dbo.fncube (3)

That is, of course, assuming that the function was created under the [dbo] schema.

Hope this helps!
Go to Top of Page

QAZAFI
Yak Posting Veteran

50 Posts

Posted - 03/24/2008 :  23:51:20  Show Profile  Reply with Quote
Hi dear
You need to put "return" not "returns" and also you have to tell which schema this function belongs to by default it belong to dbo hope this will help :)

create function fncube(@i int)
returns int
as
begin
declare @output int
set @output = power(@i,3)
return @output
end
SELECT dbo.fncube (3)
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000