Database Management
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesDatabase Management

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Dell PowerEdge Servers
  #1  
Old June 17th, 2003, 01:01 AM
ngibsonau ngibsonau is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Posts: 138 ngibsonau User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
select null is NULL

Does anybody have a good replacement for sql server 2000 for the the following

Code:
select x is NULL from tbl 


which you can test by hard coding the value for x. eg.
Code:
selcet 5 is null


and

Code:
selcet null is null


All the above sql statements work in MS ACCESS, but not MS SQL 2000

my MS SQL 2000 version is
Code:
select case when x IS NULL then 1 else 0 end from tbl


I always like to keep my SQL as portable as possible. Any body got a portable replacement for the above? What do other databases use?
__________________
--

ngibsonau

Reply With Quote
  #2  
Old June 17th, 2003, 07:23 AM
r937's Avatar
r937 r937 is offline
SQL Consultant
Dev Shed God 24th Plane (16500 - 16999 posts)
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 16,745 r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 3 Weeks 2 Days 21 h 39 m 51 sec
Reputation Power: 870
portability is probably maximized if you use standard sql, and CASE is standard

Reply With Quote
  #3  
Old June 17th, 2003, 09:29 PM
ngibsonau ngibsonau is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Posts: 138 ngibsonau User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
It doesn't seem to be standard in Access, unless I'm mistaken.

I have used the form "case when exp then statement end"
is this standard?
I wasn't aware of this form until recently. I'm more used to
"case exp when expr2 then statement end" where exp is compared with expr2 as apposed to the above where it is used just like an if statement

if exp then statement endif
case when exp then statement end

Reply With Quote
  #4  
Old June 17th, 2003, 11:07 PM
r937's Avatar
r937 r937 is offline
SQL Consultant
Dev Shed God 24th Plane (16500 - 16999 posts)
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 16,745 r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 3 Weeks 2 Days 21 h 39 m 51 sec
Reputation Power: 870
"It doesn't seem to be standard in Access, unless I'm mistaken."

you are not mistaken, ms access is not standard

like, that's a surprise?

i do not have a copy of the standard, but i'm pretty sure one of the standard CASE forms is

CASE WHEN condition THEN expression ELSE expression END

where the WHEN/THEN part can be repeated

i think another form is

CASE expression WHEN value THEN expression ELSE expression END

where again the WHEN/THEN parts can be repeated, but they're all operating on the expression after the CASE keyword

rudy

Reply With Quote
  #5  
Old June 18th, 2003, 03:24 AM
swampBoogie swampBoogie is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Jan 2003
Location: Paris Uppland
Posts: 1,746 swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 2 Weeks 3 Days 20 h 39 m 6 sec
Reputation Power: 31
You are right about the case being standard, but the statements

Code:
select x is NULL from tbl 


and

Code:
select 5 is NULL from tbl 


are also standard compliant, but not supported by many dbms. So there is no single portable statement that does what you want.

So why don't you do

Code:
select x from tbl


and then check for null in the application?


aside:

Code:
select null is NULL from tbl 


is not a st.andard compliant statement.

Reply With Quote
  #6  
Old June 19th, 2003, 02:26 AM
Hena Hena is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 28 Hena User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Quote:
Does anybody have a good replacement for sql server 2000 for the the following

select x is NULL from tbl



Not sure about what sql server is.. nor if this is any different.. but I would type it as:

select x
from tbl
where x is null

Reply With Quote
  #7  
Old June 19th, 2003, 02:26 AM
Hena Hena is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 28 Hena User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
double post

Reply With Quote
  #8  
Old June 19th, 2003, 07:08 PM
ngibsonau ngibsonau is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Posts: 138 ngibsonau User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Code:
select x is NULL from tbl 


will ALWAYS return a boolean value of true or false or in the case of sql server 0 or 1 which are the boolean values

Code:
select x from tbl where x is null

will only produce a boolean result if x is boolean and if the value of x is false it will return false when x is null!

Its not the same thing sorry.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesDatabase Management > select null is NULL


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway