If else in stored procedure sql server

后端 未结 8 1668
孤街浪徒
孤街浪徒 2021-02-02 07:19

I have created a stored procedure as follow:

Create Procedure sp_ADD_USER_EXTRANET_CLIENT_INDEX_PHY
(
@ParLngId int output
)
as
Begin
    SET @ParLngId = (Select         


        
8条回答
  •  不思量自难忘°
    2021-02-02 07:40

    If there are no matching row/s then @ParLngId will be NULL not zero, so you need IF @ParLngId IS NULL.

    You should also use SCOPE_IDENTITY() rather than @@IDENTITY.

提交回复
热议问题