Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 200
  • Last Modified:

Not Equal in where clause eliminating Nulls

Hello,

I have this query with a condition in where clause ActivityStatusId <> 100
but in the resultset it is eliminating nulls too.

How do I get around this one.

Thanks
0
rowmark
Asked:
rowmark
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
NULL must be handled :
where ( ActivityStatusId <> 100 OR ActivityStatusId IS NULL )

Open in new window

0
 
Kevin CrossChief Technology OfficerCommented:
Try this:
SELECT *
FROM your_table_name
WHERE ISNULL(ActivityStatusId, 0) <> 100

Open in new window

0
 
xbradyCommented:
You can use something like this:
(ActivityStatusId IS NULL OR ActivityStatusId <> 100)
0
Get quick recovery of individual SharePoint items

Free tool – Veeam Explorer for Microsoft SharePoint, enables fast, easy restores of SharePoint sites, documents, libraries and lists — all with no agents to manage and no additional licenses to buy.

 
Aneesh RetnakaranDatabase AdministratorCommented:
where ActivityStatusId <> 100 or ActivityStatusId IS NULL
0
 
idlirCommented:
That is because a null value is undetermined, therefore it cannot be verified whether it's different from 100

If your condition is eliminating the null values, use the following

where coalesce(ActivityStatusId ,0) <> 100


This will return all the rows that have an ActivityStatusId with a predetermined value, and all those that are null (coalesce replaces null with 0 and 0 is always different from 100 )
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
rowmark,

  glad you got your solution.
  note though that for fairness, if people post the same or alternative good solutions at the same time, you should really do a split instead of accept one of them!

angel eyes, zone advisor
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now