我收到此错误消息 102,级别 15,状态 1,过程 CostTest_02,第 43 行“;”附近的语法不正确。
用红色下划线的“GO”我一直在寻找错误,但我找不到!我对游标不是很有经验(这是我写的第一个)如果有人能发现它或任何其他错误,我将非常感谢
http://imgur.com/9k40O <----- 图片更清晰(推荐)
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
CREATE PROCEDURE CostTest_02
AS
BEGIN
DECLARE @Issue_id int;
DECLARE @Master_id int;
DECLARE @Issue_table varchar(255);
DECLARE @price real;
DECLARE @rowcount bigint;
DECLARE cost_cursor cursor FOR
SELECT [Issue Id], [Master Id], [Issue Table], [Price]
from Adhoc_datafix..[Issue Table]
FOR UPDATE OF ADHOC_DATAFIX..[Issue Cost];
OPEN cost_cursor;
FETCH NEXT FROM cost_cursor into @Issue_ID, @Master_id, @Issue_table, @Price
WHILE @@FETCH_STATUS = 0
BEGIN
Select count(*) from @Issue_Table
set @Rowcount = @@rowcount
UPDATE ADHOC_DATAFIX..[Issue Cost]
set [Issue Id] = @Issue_ID ,
[Master Issue Id] = @Master_ID ,
[Row Count] = (Select count(*) from @Issue_Table), --@Rowcount,
[Cost] = CAST(@Rowcount * @price as money)
WHERE CURRENT OF cost_cursor;
FETCH NEXT FROM cost_cursor
END
close cost_cursor;
DEALLOCATE cost_cursor;
GO