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

  • Home
  • SEARCH
  • 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 5846285
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:33:18+00:00 2026-05-22T12:33:18+00:00

I have a Product table with non-null quantity (decimal) and status (int) columns, and

  • 0

I have a Product table with non-null “quantity” (decimal) and “status” (int) columns, and I created a view on this table with the following case expression:

SELECT P.ProductTypeId,
       (CASE WHEN P.StatusId IN (5, 8) THEN 0 ELSE -P.Quantity END) AS Quantity,
       ...
FROM Product P

ProductTypeId is correctly inferred as non-null. However, the Quantity column of this view is inferred as nullable, even though the underlying columns are not nullable. This doesn’t make any sense to me.

I could use ISNULL/COALESCE to provide a default value in this case and force non-nullability, but there is no meaningful default value, and this shouldn’t happen in the first place from what I understand. Any ideas what’s going on?

  • 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-22T12:33:19+00:00Added an answer on May 22, 2026 at 12:33 pm

    The below explanation is for computed columns in a table. I imagine the same applies to computed columns in a view.

    The Database Engine automatically
    determines the nullability of computed
    columns based on the expressions used.
    The result of most expressions is
    considered nullable even if only
    nonnullable columns are present,
    because possible underflows or
    overflows will produce null results as
    well. Use the COLUMNPROPERTY function
    with the AllowsNull property to
    investigate the nullability of any
    computed column in a table. An
    expression that is nullable can be
    turned into a nonnullable one by
    specifying ISNULL(check_expression,
    constant), where the constant is a
    nonnull value substituted for any null
    result.

    An example where your expression could return NULL is

    SET ARITHABORT OFF;
    SET ANSI_WARNINGS OFF;
    
    WITH Product(Quantity,StatusId) As
    (
    SELECT -2147483648,1
    )
    SELECT (CASE WHEN P.StatusId IN (5, 8) THEN 0 ELSE -P.Quantity END) AS Quantity  
    FROM Product P
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables, like so: table a contains: id|name stock1|fullname stock2|fullname2 stock3|fullname3 table
I have an affiliate link with a product image http://www.myaffiliate.com/products/product.jpg I want to copy
I have a process that imports a daily file of product registrations, and adds
Heres the situation, a database was created and not normalized. The table LUT_ProductInfo contains
What is the best/correct way to translate for example a product description that is
I am trying to figure out a good way to handle the following scenario
THE TABLES: Shop Product Category THE RELATIONSHIPS: (Shop) 1 <---> n (Categories) (Shop) 1
Using Doctrine 2. I have an entity called 'size' and I'm trying to form
For certain products in my Database, The name of the product will get cut

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.