Boolean Test

  • I know that there is not a boolean datatype but instead a bit type.  But is there a way to create SQL statements testing for True and False instead of 1 and 0?

  • Lets say that Field1 is a BIT DataType.

    DECLARE @Param VARCHAR (5)

    If Field1 = 1

      BEGIN

        SET @Param = 'True'

    ELSE

        SET @Param = 'False'

        END


    Kindest Regards,

  • I'm more interested in something like:

    "select * from Funds where IsLive = True"

    where IsLive is a bit field.

     

  • You cannot use the words True/False as they are reserved words in SQL. The nearest you can get to your requirement is to check against character representation of True/False

    select * from Funds

    where (CASE WHEN ISNULL(IsLive,0) = 1 THEN 'True' ELSE 'False' END)= 'True'

    Far away is close at hand in the images of elsewhere.
    Anon.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply