Topic:Problem testing for "<NULL>" in an SQL Server database table column. Remainpoint:0
   
PostTime:12/16/2008 12:00:42 AM FloorTop
Lv is 1
Avatar
Level:
1
Professional point:
81
Experience:
32
Thread:
281
Post:
990
Total online time:
32M
Joined date:
4/29/2007 12:22:00 AM
Last Visit:
12/17/2008 12:54:30 AM
Status:
Offline
I am puzzled. I have a column CalloutName in one of the tables in an SQL Server database. That column CalloutName has either a string or a NULL (as in <NULL>).
(A) If there is no gap/space between the entry <NULL> and the left boundary of a column, the entry is treated as a NULL.
(B) If there is a gap/space between the entry <NULL> and the left boundary of a column, the entry is treated as not NULL.

(A) and I can use the following to test whether it is really a NULL:

If IsNull(!CalloutName) Or !CalloutName = "" Then
callOutState = "" (path for A)
Else
callOutState = !CalloutName (path for B)
End If

So, I tried the following code to see whether the entry in (B) can be picked up as a NULL.

Dim iPosNULL As Integer
iPosNULL = InStr(4, !CalloutName, "NULL>", 1)

If IsNull(!CalloutName) Or !CalloutName = "" Or iPosNULL <> 0 Then
callOutState = ""
Else
callOutState = !CalloutName
End If

I got an error:

and got an error: Inavalid use of NULL.

So, I am at a loss; how do I test the Nullity of such an entry.
 
     
   
Gender PostTime:12/16/2008 3:59:09 PM Point:0 | Floor# 1
Lv is 1
portrait
Level:
1
Professional point:
5
Experience:
28
Thread:
261
Post:
1005
Total online time:
28M
Joined date:
4/29/2007 2:32:00 AM
Last Visit:
12/17/2008 12:22:50 AM
Status:
Offline
Use the If CalloutName = "" I do not think IsNull will work in all datatypes. You might also want to put a Trim in front of your column name to trim off any white space that is either inadvertently put in there or is there by default.
 
     
1

Sorry, you are not login, click here to login

 

About us | Advertise | Contact us | Partner | Bug Report|Suggesting box|Donation
Home | Forum | Affiliate program| Remote help | Setting | Search | Document | Help | Download|Message

 

Start new topicAdvanced search
Your location: Database -> Sql server