I have an sp in SQL Server that when errors returns -4
What does -4 mean? Is there a table somewhere explaining what the possible return values are?
Th
There is no standard for return codes. You'll have to find out what -4 means in that particular stored procedure. In fact, not all return codes are errors.
EDIT: counter-example
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[RetValTest]
AS
BEGIN
select 1/0;
END
GO
Execution:
DECLARE @return_value int
EXEC @return_value = [dbo].[RetValTest]
SELECT 'Return Value' = @return_value
GO
Result:
Msg 8134, Level 16, State 1, Procedure RetValTest, Line 9
Divide by zero error encountered.
This is with SQL Server 2008.
Some research suggests that this behavior may be left over from SQL Server 6.0. If that is the case, then you can decide for yourself how reliable it's likely to be, given that they stopped documenting it (and stopped guaranteeing its accuracy) so long ago.
My "research" is due, with thanks, to SQL Server MVP Tibor Karaszi. His source is Books Online for SQL Server 6.5. Under ""Control-Of-Flow Language", RETURN", he found
"SQL Server reserves 0 to indicate a successful return and reserves negative values from - 1 through - 99 to indicate different reasons for failure. If no user-defined return value is provided, the SQL Server value is used. User-defined return status values should not conflict with those reserved by SQL Server. The values 0 through -14 are currently in use.