USE [Bonakdar_DB]
GO
/****** Object: StoredProcedure [dbo].[SP_Inventory] Script
Date
: 06/11/2015 11:35:36 ?.? ******/
SET
ANSI_NULLS
ON
QUOTED_IDENTIFIER
ALTER
PROCEDURE
[dbo].[SP_Inventory]
AS
DECLARE
@income
INT
= (
select
sum
(Quantity)
from
View_Inventory
where
[Type_Bool] = 1
group
by
[Commodity_Id])
@outcome
[Type_Bool] = 0
@uotput
TABLE
(
commo_Id
int
,
nam nvarchar(20),
quant
uni nvarchar(50),
typ nvarchar(10),
dat datetime )
INSERT
SELECT
[Commodity_Id], [
Name
], [Quantity], [Unit], [Type], [
]
FROM
BEGIN
NOCOUNT
;
commo_Id, nam, quant, (@income - @outcome)
inventory, uni, typ, dat
ORDER
BY
dat
END