Tuesday, 23 July 2019

MSSQL - How to exit stored procedure

Watch this example on YouTube


 
Replace

ALTER PROCEDURE spTestExit
AS
BEGIN
    SET NOCOUNT ON;

    Select * from TestTable
END
GO

exec spTestExit 'sss'
exec spTestExit null

With

ALTER PROCEDURE spTestExit
    @Name varchar(50)
AS
BEGIN
    SET NOCOUNT ON;

    if @Name Is null
    Begin
        Return
    End


    Select * from TestTable
END
GO

exec spTestExit 'sss'
exec spTestExit null

No comments:

Post a Comment