[英]Incorrect syntax near '@ItemID'
I am not sure that writing SP with two update statements correct. 我不确定用两个更新语句编写SP是否正确。
I am getting Incorrect syntax near '@ItemID'. 我在'@ItemID'附近收到语法错误。 Can you suggestion me ... How can i resolve this.
您能建议我吗?我该如何解决。
CREATE PROCEDURE [dbo].[ComponentReplaceUSP](@ReplaceItem nvarchar(256) ,@Quantity decimal(28,12) ,@UOM nvarchar(30))
AS
DECLARE @ItemID INT
BEGIN
Select @ItemID = ItemID FROM [dbo].[Item] WHERE ItemName = @ReplaceItem
UPDATE Item
SET Item.ItemName = @ReplaceItem,
Item.UOM = @UOM
Where Item.ItemID =@ItemID
Update ItemBillOfMaterial
Set ItemBillOfMaterial.UOM =@UOM,
ItemBillOfMaterial.Quantity =@Quantity
Where ItemBillOfMaterial.CompItem= @ItemID
Your CREATE PROCEDURE
query requires an END
: 您的
CREATE PROCEDURE
查询需要END
:
CREATE PROCEDURE [dbo].[ComponentReplaceUSP](@ReplaceItem nvarchar(256) ,@Quantity decimal(28,12) ,@UOM nvarchar(30))
AS
DECLARE @ItemID INT
BEGIN
Select @ItemID = ItemID FROM [dbo].[Item] WHERE ItemName = @ReplaceItem
END
It should be just a case of moving the declare below the begin as this needs to be declared within the SP. 这只是将声明移到开始位置以下的一种情况,因为这需要在SP中进行声明。
http://msdn.microsoft.com/en-us/library/ms187926.aspx http://msdn.microsoft.com/en-us/library/ms187926.aspx
It will complain about whatever the last part of the last query is, because you've forgotten to END
the block you BEGIN
at line 5. 它会抱怨无论最后一次查询的最后一部分是,因为你忘了
END
你块BEGIN
第5行。
The accepted answer is wrong with its main assertion that is has anything to do with the DECLARE
statement. 接受的答案与其主要断言有误,该主断言与
DECLARE
语句有关。 The following is fine: 很好:
create procedure ABC
as
declare @ID int
begin
select @ID = object_id from sys.objects
end
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.