Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4585352
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T21:28:57+00:00 2026-05-21T21:28:57+00:00

according to this question , I can’t assign the result of a boolean logic

  • 0

according to this question, I can’t assign the result of a boolean logic statement into a bit field. My problem is that I am working on a creation script and I have a few dependent flags that require a boolean statement to complete. This script will start as all nulls and the user just enters the data they want to. The script will detect if the record already exists. If so, it will update only the parameters that are not null. If it doesn’t exist, the script will create a new record. I am using sql server 2005.

I have the insert statement figured out using ISNULL(@Setting1, 0) to set a default value when the variable is not assigned. My problem comes with one particular setting which is dependent on 2 of the setting flags. I’d also like to see a solution that could support another setting flag if I needed to add one.

DECLARE @Setting1 bit
DECLARE @Setting2 bit
DECLARE @Setting3 bit

--... code snipped for setting the value

UPDATE
    MyTable
SET
    EnableSetting1 = ISNULL(@Setting1, EnableSetting1),
    EnableSetting1 = ISNULL(@Setting2, EnableSetting2),
    EnableSetting1 = ISNULL(@Setting3, EnableSetting3),
    EnableComplexSetting1 = ISNULL(@Setting1, EnableComplexSetting1),
    EnableComplexSetting2 = ?
WHERE
    Id = @MyId

Logically, the ? would look like ISNULL(@Setting2, EnableSetting2) OR ISNULL(@Setting3, EnableSetting3) but that is obviously incorrect. How should I set the complex setting 2? How would I do it if logically it was ISNULL(@Setting2, EnableSetting2) OR ISNULL(@Setting3, EnableSetting3) OR ISNULL(@Setting4, EnableSetting4), etc?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T21:28:58+00:00Added an answer on May 21, 2026 at 9:28 pm

    ISNULL doesn’t return a boolean – it just makes sure to use the second value provided IF the first expression is NULL.

    You’ll need to use something like this:

    UPDATE
        MyTable
    SET
        EnableSetting1 = CASE WHEN @Setting1 IS NULL THEN 1 ELSE 0 END,
    ...
    

    Depending on which boolean you want to store if @Setting1 is really NULL you might need to switch the two values in the THEN and ELSE cases….

    With this approach you should be able to also check two conditions:

    UPDATE MyTable
    SET EnableComplexSetting2 = 
            CASE WHEN (Complex1 IS NULL AND Complex2 IS NULL) THEN 1 ELSE 0 END 
    
     ......
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

According to this question it seems like you can do this for Methods. What
I have a problem similar to this question: Wicket: can Checkgroup be Ajax enabled?
According to this question, we can change keyboard appearance of any UITextField in iOS
According to this question I succeeded to create upload image, but now I need
According to this question in order for Flymake to work you must add a
I didnt find anything according this issue. Can jaas be used to secure my
According to this post in Recursive Descent vs. LALR , any LALR(k) can be
This question is about making an architectural choice prior to delving into the details
I know that this question seems illogical, but I have to try, and I
According to this article I know, that DateTimePicker control does not reflect CurrentUICulture So,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.