[Solved] SQL Server Stored Procedure Error: incorrect syntax near else

makumbi
 
on Jul 08, 2022 07:35 AM
434 Views

Please help I am getting the error below

incorrect syntax near else

CREATE PROCEDURE [dbo].[P3P7marksheetLast]@C nvarchar(50) AS
	if @C='P3'
begin
	exec deletedestemp
	exec Classgeneral @C
 
	exec Delnulpositions
	exec deletedestemp
	Update destinationtemp set pos= case when division ='x' then 100000 else pos end
	exec Delnulpositions2
else 
begin
	exec destinationdelete
	exec Generalupperp @c
	exec Runclassposition
	Update destination37 set pos= case when division ='x' then 100000 else pos end
end

 

Download FREE API for Word, Excel and PDF in ASP.Net: Download
dharmendr
 
on Jul 08, 2022 07:46 AM
on Jul 09, 2022 08:26 AM

Hi makumbi,

End is missing for Begin.

Use this.

CREATE PROCEDURE [dbo].[P3P7marksheetLast]
	@C nvarchar(50) AS
begin
	if @C='P3'
	BEGIN
		exec deletedestemp
		exec Classgeneral @C
 
		exec Delnulpositions
		exec deletedestemp
		Update destinationtemp set pos= case when division ='x' then 100000 else pos end
		exec Delnulpositions2
	END
	else
	begin
		exec destinationdelete
		exec Generalupperp @c
		exec Runclassposition
		Update destination37 set pos= case when division ='x' then 100000 else pos end
	end
END