Im getting this error Msg 102, Level 15, State 1, Procedure CostTest_02, Line 43 Incorrect syntax near ';'.
With "GO" underlined in red I've been looking for the error for a while and I can't find! I'm not very experienced with cursors( this is the first one I've written) If anyone can spot it or any other errors I'd be very thankful
https://i.sstatic.net/JwB1w.jpg <----- picture is a lot more clear(recommended)
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