charan1976
Programmer
I have a simple Stored Procedure I'm trying to create as follows:
========================================
CREATE Proc CalcInventory
@ItemNo varchar
AS
CREATE VIEW Get_Qty AS
SELECT SUM(Quantity) AS TotalQty
FROM [Tech Chem Corp_$Item Ledger Entry]
WHERE [Tech Chem Corp_$Item Ledger Entry]."Item No_" = '00-0314'
GO
UPDATE [Tech Chem Corp_$Item]
SET [Tech Chem Corp_$Item]."Inventory Calc_" = (SELECT TotalQty FROM GET_QTY)
WHERE [Tech Chem Corp_$Item]."No_" = '00-0314'
drop view get_qty
GO
===========================================
I'm getting the error:
Server: Msg 156, Level 15, State 1, Procedure CalcInventory, Line 4
Incorrect syntax near the keyword 'VIEW'.
Can someone point out what I'm doing wrong here?
TIA
========================================
CREATE Proc CalcInventory
@ItemNo varchar
AS
CREATE VIEW Get_Qty AS
SELECT SUM(Quantity) AS TotalQty
FROM [Tech Chem Corp_$Item Ledger Entry]
WHERE [Tech Chem Corp_$Item Ledger Entry]."Item No_" = '00-0314'
GO
UPDATE [Tech Chem Corp_$Item]
SET [Tech Chem Corp_$Item]."Inventory Calc_" = (SELECT TotalQty FROM GET_QTY)
WHERE [Tech Chem Corp_$Item]."No_" = '00-0314'
drop view get_qty
GO
===========================================
I'm getting the error:
Server: Msg 156, Level 15, State 1, Procedure CalcInventory, Line 4
Incorrect syntax near the keyword 'VIEW'.
Can someone point out what I'm doing wrong here?
TIA