user1679941
user1679941

Reputation:

How can I make a Stored procedure return a bit value?

I have a stored procedure similar to this:

CREATE PROCEDURE [dbo].[sp_mark_question]
AS
BEGIN
   SELECT  1 AS Authenticated,
           0 AS RC
END

It is executed like this:

var rc = await db.Database.SqlQuery<AnswerToClient>(sql).FirstOrDefaultAsync();

public class AnswerToClient
{
    public bool Authenticated { get; set; }
    public bool RC { get; set; }
}

I get an error:

The specified cast from a materialized 'System.Int32' type to the 'System.Boolean' type is not valid.

I think this might be because the stored procedure returns a number. How can I make it return a value that can be converted to the bool?

Upvotes: 1

Views: 1156

Answers (1)

Rob Farley
Rob Farley

Reputation: 15849

SELECT CAST(1 AS BIT) AS Authenticated

Upvotes: 2

Related Questions