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 6106141
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:02:52+00:00 2026-05-23T14:02:52+00:00

Here is my example view (contrived I know but shows my problem): CREATE VIEW

  • 0

Here is my example view (contrived I know but shows my problem):

CREATE VIEW NullTest
AS
SELECT
    1 AS IntNoConvert, 
    CONVERT(BIT, 1) AS IntConvert, 
    CAST(1 AS BIT) AS IntCast

The final views as the data types as:

IntNoConvert (int, not null)
IntConvert (bit, null)
IntCast (bit null)

So the CONVERT and CAST make the column allow NULLs – not normally a problem in views but am I am using LinqToSql ontop of this, I need the datatypes to be NOT NULL.

Any ideas how to make the CONVERT statement return the data as NOT NULL?

  • 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-23T14:02:53+00:00Added an answer on May 23, 2026 at 2:02 pm

    Use the SQL IsNull function to ensure non-nullability:

    CREATE VIEW NullTest
    AS
    SELECT
        1 AS IntNoConvert, 
        IsNull(CONVERT(BIT, 1), 1) AS IntConvert, 
        IsNull(CAST(1 AS BIT), 1) AS IntCast
    

    This feels a little hacky so I agree with a1ex07’s comment that you should define the non-nullability in your model instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This problem is not readily reproducible in a simple example here but was wondering
Here is an example view named MANVW : SELECT manager_id, manager_sign FROM ( SELECT
What does this do? I find the example here, but other than what it
Here is an example of what I've got going on: CREATE TABLE Parent (id
Here is an example grid-view: Also another example from TED.com Any ideas on how
Here's an example view, I use it to output every Category in my database.
Both exist for example here: Map.empty[Int, Int] Map(1 -> 41).empty Set().empty Set.empty But here
I have the dropdowns in my Create() View working perfect. But in the Edit()
The fictional example here. Suppose I designed a class named IODevice. This class already
I found a great C++/ODBC example here ... The project I downloaded builds great

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.