Hello,
I created a stored procedure in ms sql server. The stored procedure subtracts two columns in the same table. How do I insert this stored procedure data into the Inventory column of an existing table dbo.Store? The stored procedure is:
ALTER PROCEDURE [dbo].[sp.StoreBilling]
AS
BEGIN
SET NOCOUNT ON;
DECLARE @Stock decimal(10,2)=0.00
DECLARE @Spoilage decimal(10,2)=0.00
SELECT A.Stock, A.Spoilage, A.Stock-A.Spoilage AS Inventory
FROM dbo.Store AS A
END
What I have tried:
ALTER PROCEDURE [dbo].[sp.StoreBilling]
AS
BEGIN
SET NOCOUNT ON;
DECLARE @Stock decimal(10,2)=0.00
DECLARE @Spoilage decimal(10,2)=0.00
SELECT A.Stock, A.Spoilage, A.Stock-A.Spoilage AS Inventory
FROM dbo.Store AS A
INSERT INTO dbo.Store
OUTPUT Inventory
VALUES(@Stock-@Spoilage);
END
Error message:
Msg 213, Level 16, State 1, Procedure sp_StoreBilling, Line 20 [Batch Start Line 7]
Column name or number of supplied values does not match table definition.