在表库存中添加数据

在表库存中添加数据

本文介绍了如何编写存储过程以在表库存中添加数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何编写用于在表库存中添加数据的商店程序

i有这个但不能正常工作....

how to write a store procedure for add data in table inventory out
i have this but not working....

ALTER Procedure [dbo].[SpAddInventory_Out]
LTER Procedure [dbo].[SpAddInventory_Out]
@ID int,
@CampusID int,
@Item_ID int,
@Store_ID int,
@Quentity int,
@TotalAmount float,
@Rate float,
@Date_of_Order datetime,
@Date_of_Delivery datetime,
@DeliverBy int,
@ReceivedBy int,
@Remarks nvarchar(Max),
@CreatedBy int,



AS
BEGIN
IF((Select COUNT(*) from Inventory_Out where ID=@ID)>0)
BEGIN

UPDATE Inventory_Out SET 

CampusID=@Campus_ID,
Item_ID=@Item_ID,
Store_ID=@Store_ID,
Quentity =@Quentity,
TotalAmount =@TotalAmount,
Rate =@Rate,
Date_of_Order =@Date_of_Order,
Date_of_Delivery =@Date_of_Delivery,
DeliverBy =@DeliverBy,
ReceivedBy =@ReceivedBy,
CreatedDate=GETDATE(),
Remarks =@Remarks,
CreatedBy =@CreatedBy,


where ID =@ID
END

ELSE

BEGIN

INSERT INTO Inventory_Out (CampusID,Item_ID,Store_ID,Quentity,Rate,TotalAmount,Date_of_Order
,Date_of_Delivery,DeliverBy,ReceivedBy,Remarks,CreatedBy,CreatedDate) 

Values (@Item_ID,Store_ID, @CampusID,@Quentity,@Rate,@TotalAmount,@Date_of_Order
,@Date_of_Delivery,@DeliverBy,@ReceivedBy,@Remarks,@CreatedBy,GETDATE())

END
        
Select ID, Item_ID,Store_ID,CampusID,Quentity,Rate,TotalAmount,Date_of_Order
,Date_of_Delivery,DeliverBy,ReceivedBy,Remarks,CreatedBy,CreatedDate from Inventory_Out

END

推荐答案

--additional alter with missing missing A, to be removed
LTER Procedure [dbo].[SpAddInventory_Out]

--extra comma in
@CreatedBy int,

--and
CreatedBy =@CreatedBy,

--use of parameter, sometimes used
@CampusID int,

--used in update query with underscore _
CampusID=@Campus_ID,



如果有解决方法,请告诉我。


Let me know if that fixes it.


这篇关于如何编写存储过程以在表库存中添加数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-10 00:40