How to return bool from stored proc
Use this:
SELECT CAST(1 AS BIT)
You can't. There is no boolean datatype and the procedure return code can only be an int
. You can return a bit
as an output parameter though.
CREATE PROCEDURE [dbo].[ReturnBit]
@bit BIT OUTPUT
AS
BEGIN
SET @bit = 1
END
And to call it
DECLARE @B BIT
EXEC [dbo].[ReturnBit] @B OUTPUT
SELECT @B
You have at least 2 options:
SELECT CONVERT(bit, 1)
SELECT CAST(1 AS bit)