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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T15:57:39+00:00 2026-06-04T15:57:39+00:00

Suppose I have a table like: Tab(MyDate datetime null, MyIs bit null, …) Then

  • 0

Suppose I have a table like:

Tab(MyDate datetime null, MyIs bit null, ...)

Then I have SQL Like

    select Isnull(MyDate, 1), IsNull(MyIs, 999) from Tab;

If MyDate, MyIs value is null in DB, the result is:

    MyDate                   MyIs  
    1900-01-02 00:00:00.000  1

Not the expected value like

MyDate        MyIs  
1             999

So it looks like the return value is based on data type of the column.
How to resolve this issue?

For my testing case as above, I Only got one row from the table.

  • 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-06-04T15:57:41+00:00Added an answer on June 4, 2026 at 3:57 pm

    The way you’re looking for, you don’t.

    All the values in the same column must be the same data type. If your data had NOT NULL values in some rows (returning the column’s data-type) and NULL values in other rows (returning a different data type, as per your CASE statement), you would break this requirement.

    You could have two extra fields…

    select
      MyDate,
      CASE WHEN MyDate IS NULL THEN 1   ELSE 0 END As MyDateWibble,
      MyIs,
      CASE WHEN MyIs   IS NULL THEN 999 ELSE 0 END AS MyIsWibble
    FROM
      Tab;
    

    You could CAST() everything to VARCHAR() and return strings instead of DATETIME, BIT or INT.

    But, more probably, I’d review the reason you want to do this in the first place and work out an alternative design.

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

Sidebar

Related Questions

Suppose I have a table with data like: Tab(id, name) 1, 'Name 1' 2,
Suppose I have a table like CREATE TABLE associacao ( id bigserial NOT NULL,
Suppose I have a table like: create table { id numeric(5,3), code varchar(10) }
Suppose you have a table like this: id user score It's a dump of
Suppose I have a table of users. Something like: ID integer, USER text, POSITION
I have requirement like, suppose I have a 'property' table which has 'ListingKey' field
Suppose you have a table in SQL: Prices ------ 13.99 14.00 52.00 52.00 52.00
Suppose I have a table like so: <table> <tr><td class=this-is-a-label>Label Cell</td></tr> <tr><td>Detail 1</td></tr> <tr><td
Suppose I have a table that contains valid data. I would like to modify
Suppose that I have a table like: class Ticker(Entity): ticker = Field(String(7)) tsdata =

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.