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
If there are no matching row/s then @ParLngId will be NULL not zero, so you need IF @ParLngId IS NULL.
@ParLngId
NULL
IF @ParLngId IS NULL
You should also use SCOPE_IDENTITY() rather than @@IDENTITY.
SCOPE_IDENTITY()
@@IDENTITY