How can I check if my TSQL stored procedure updated within the stored procedure in order to create a proper message?
Example:
ALTER PROCEDURE [dbo].[pUpdate]
@id uniqueidentifier,
@status int,
@message VARCHAR(100) OUTPUT
AS
BEGIN
SET NOCOUNT ON;
UPDATE [database].[dbo].[user]
SET status = @status
WHERE Id = @id
END
IF (SUCCESSFUL)
BEGIN
@message = 'Success!'
END
What are some possible ways to check if successful without using the parameters again?
This is what I currently use:
SELECT COUNT(*)
WHERE status = @status AND id = @id
Are there any other ways? I want to know for my knowledge and reference. Thanks.