Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Exec function in sp
Message
From
11/10/2007 16:59:58
Issam Mansour
Jordan Business Machines
Amman, Jordan
 
 
To
All
General information
Forum:
Microsoft SQL Server
Category:
Stored procedures, Triggers, UDFs
Title:
Exec function in sp
Environment versions
SQL Server:
SQL Server 2005
Miscellaneous
Thread ID:
01260434
Message ID:
01260434
Views:
48
Hi,

How to exec the following function from my select statement runnimg in large data selection in sp and get my return value each time:-

ALTER FUNCTION [dbo].[fn_qty]
(@qty decimal (10,4),
@price decimal (10,4),
@pieces int,
@mpt int=0)

returns decimal (10,4)

AS
begin
declare @totamt decimal (10,4)
if @pieces = 0
begin
SET @totamt = (@QTY * @price)
end
else
begin
SELECT @mpt = (SELECT case mpq
when 1 then 10
when 2 then 100
else 100
end
FROM ims.parm)
SET @totamt=(((FLOOR(@QTY)*@PRICE))+(((@qty-FLOOR(@QTY))* @mpt)/@pieces)*@price)
end
return @totamt
end

I can exec the function as exec command as follows:-
exec @totamt( erpinv.dbo.fn_qty 3.5,6,24 )


Best Regards
Next
Reply
Map
View

Click here to load this message in the networking platform