Results 1 to 5 of 5
  1. #1
    Join Date
    Sep 2009
    Posts
    11

    Question Unanswered: CBool Access SQL function analog

    Hello kind peaple.

    In Access SQL I was able to write in such manner:
    SELECT CBOOL([Client] Like '%Corp%') AS IsCorp FROM tblMain
    How to correctly convert this expression to T-SQL?
    Is there a laconic possibility without CASE WHEN... construction?

    Thanks in advance.

  2. #2
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    Quote Originally Posted by sv2k
    How to correctly convert this expression to T-SQL?
    Yes.
    But since you have not explained exactly what this does, what behavior your expect, or given any sample input and output, I can't tell you how.
    Try again.
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  3. #3
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Code:
    SELECT Convert(bit, (CASE WHEN [client] LIKE '%Corp%' THEN 1 ELSE 0 END) As IsCorp
    FROM   tblMain
    George
    Home | Blog

  4. #4
    Join Date
    Nov 2004
    Posts
    1,427
    Provided Answers: 4
    Do you have to parse the client string to know whether it is a client corporation? That is bad design. You should add an explicit column like IndCorp or CorpFlag, ... or a FK to a table holding all possible values, to store that property.

    In my tables IndColumns are indicator columns of type CHAR(1) with a check constraint limiting their values e.g. CHECK (IndColumn IN ('Y', 'N')). You could also use BIT instead of CHAR(1), but that is not standard SQL.
    With kind regards . . . . . SQL Server 2000/2005/2012
    Wim

    Grabel's Law: 2 is not equal to 3 -- not even for very large values of 2.
    Pat Phelan's Law: 2 very definitely CAN equal 3 -- in at least two programming languages

  5. #5
    Join Date
    Sep 2009
    Posts
    11
    I need tick (checkboxes in table) in the field 'IsCorp' to be shown in the front-end interface at users. So, the field must be boolean type ('bit' in T-SQL).

    I've understood.

    Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •