NEED storedproc for calculating totalcost

Posted by Parthibansk under Sql Server on 12/5/2012 | Points: 10 | Views : 690 | Status : [Member] | Replies : 1
i got a table
PRODUCTMASTER

PRODUCTID COMPANYID NAME UNITS COST TOTAL

NEED A STOREPROC OR FUNCTION FOR CALCULATING TOTALCOST..WHEN I ENTER UNITS AND COST AS INPUTS..TOTAL SHOULD BE REFLECTED IMMED..
I HAVE WRITTEN STOREDPROC LIKE THIS:

CREATE PROC [dbo].[PRDTOTAL](@UNITS INT, @COST DECIMAL(5,2)) AS BEGIN
DECLARE @TOTAL AS NUMERIC(38,0)
SET @TOTAL =@UNITS*@COST
PRINT
@TOTAL
END
GO

NEED ASP.NET CODE FOR THE SAME




Responses

Posted by: Pavanandey on: 12/6/2012 [Member] Bronze | Points: 25

Up
0
Down
CREATE PROC [dbo].[PRDTOTAL]
@PRODUCTID Int,
@COMPANYID Int,
@NAME varchar(50),
@UNITS INT,
@COST DECIMAL(5,2)
AS
BEGIN
SET NOCOUNT ON;
INSERT INTO PRODUCTMASTER(PRODUCTID,COMPANYID,NAME,UNITS,COST,TOTAL)
VALUES (@PRODUCTID,@COMPANYID,@NAME,@UNITS,@COST,@UNITS*@COST)
END

Thanks
Pavan Kumar
Mark Answer if this fits the need

Parthibansk, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response