Are instructions executed after END is completed in the stored procedure?

Are instructions executed after END is completed in the stored procedure?

I found that the my stored procedure includes the delete procedure after the BEGIN / END block. However, every time I execute a stored procedure elsewhere in the code, it works fine and pvd_sp_yyy is not discarded. I'm not sure why? I worry about this in the first place, and so I'm going to remove the extra expression independently.

Does anyone have any ideas about this?

thanks

set ANSI_NULLS ON set QUOTED_IDENTIFIER ON go ALTER PROCEDURE [dbo].[pvd_xxx] @var AS BEGIN DECLARE @RETURN int SET @RETURN = 0 IF EXISTS ( SELECT * FROM table1 WHERE name = @var ) BEGIN SET @RETURN = 1 END RETURN @RETURN END IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[pvd_sp_yyy]') AND type in (N'P', N'PC')) DROP PROCEDURE [pvd_sp_yyy] 
+4
source share
3 answers

BEGIN / END are not limits of stored procedure. The end of the party (usually GO) is.

So yes, the code is executed.

It also means that BEGIN / END is not needed ... like brackets around parameters. This is SQL: not a high-level client language.

I pretty often left GRANT EXECUTE inside the stored procedure ... :)

+7
source

Yes, since everything you declared is a block of code. The contents of the procedure do not end until you put GO to execute the package.

+2
source

If you really want DROP PROCEDURE executed, it should be the only statement in the package, so separate ALTER PROCEDURE and DROP PROCEDURE from GO .

0
source

All Articles