I’m wondering if this is a good practice or not. I have a database with a few stored procedures which I run using C# application.
Is it a good practice to return messages from stored procedures which can directly be shown to the application user?
For example:
CREATE PROCEDURE CheckParam
@Param int,
AS
BEGIN
IF (@Parem > 0)
BEGIN
SELECT 'Parameter is greater than 0'
END
ELSE SELECT 'Parameter is smaller than 0'
END
It would generally be considered best practice to have the code layer set the message text as this allows future maintainers of the code to clearly follow the intended logic.