Example Stored Procedure: UPDATE

/***********************************************************************************************/
PRINT 'UpdateRGConversation';
/***********************************************************************************************/
GO
IF EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_NAME = N'UpdateRGConversation' AND ROUTINE_TYPE = N'PROCEDURE' AND ROUTINE_SCHEMA = N'dbo')
    DROP dbo.PROCEDURE UpdateRGConversation
GO
CREATE PROCEDURE dbo.UpdateRGConversation (
    @ConversationID  int,
    @Active          bit,
    @ChangedByUserID int,
    @Description     varchar(255)
) AS
/*
    Update the Status of a bill
*/
BEGIN
    SET NOCOUNT ON

    DECLARE @error    int
    DECLARE @list     nvarchar(512)
    DECLARE @rowcount int
    DECLARE @spName   sysname

    SELECT @spName = Object_Name(@@ProcID)

    UPDATE dbo.RGConversation
    SET
        Active          = @Active,
        ChangedByUserID = @ChangedByUserID,
        Description     = @Description,
        DateLastUpdated = GETDATE()
    WHERE ConversationID = @ConversationID

    SELECT
        @error    = @@error,
        @rowcount = @@rowcount

    IF @error <> 0 OR @rowcount <> 1 BEGIN
        EXEC dbo.TagValueList @list OUTPUT, 'ConversationID', @ConversationID, 'Active', @Active, 'ChangedByUserID', @ChangedByUserID, 'Description', @Description

        IF @error <> 0 BEGIN
            RAISERROR(990002, 10, 1, @error, @spName, 'RGConversation', @list)
            RETURN(@error)
        END
        ELSE IF @rowcount <> 1 BEGIN
            RAISERROR(990006, 10, 1, @spName, 'RGConversation', @rowcount, @list) WITH SETERROR
            RETURN(@@error)
        END
    END

    RETURN(0)
END
GO