• There are a couple of errors in your merge.

    I would ask you ID is a varchar(10) when you have the ID as an IDENTITY in your original User table creation script.

    It seems that you are passing in the ID of the user so that forms the Unique lookup reference as a

    CREATE PROCEDURE [dbo].[usp_UsersRegistration]

    @ID VARCHAR(10),

    @Username VARCHAR(50),

    @Password VARCHAR(50)

    AS

    DECLARE @Action TABLE ([Action] varchar(100))

    DECLARE @Ret tinyint

    MERGE [dbo].[Users] AS [Target]

    USING (SELECT @ID Id, @Username [Username], @Password [Password])

    ON [Target].[Id] = [Source].[Id]

    WHEN MATCHED THEN

    UPDATE SET

    [UserName] = [Source].[Username]

    ,[Password] = [Source].[Password]

    WHEN NOT MATCHED THEN

    INSERT ( [Username]

    , [Password] )

    VALUES ( [Source].[Username]

    , [Source].[Password]);

    OUTPUT

    $Action

    INTO @Action

    Select @Ret=(Select CASE [Action] WHEN 'Update' Then 1 Else 0 end From @Action)

    Return @Ret

    GO

    This should then Return -1 when an Update is executed and a 0 when an insert is executed.

    _________________________________________________________________________
    SSC Guide to Posting and Best Practices