Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Exec function in sp
Message
De
11/10/2007 16:59:58
Issam Mansour
Jordan Business Machines
Amman, Jordanie
 
 
À
Tous
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
Titre:
Exec function in sp
Versions des environnements
SQL Server:
SQL Server 2005
Divers
Thread ID:
01260434
Message ID:
01260434
Vues:
49
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform