Results 1 to 3 of 3

Thread: Function

  1. #1
    Join Date
    Dec 1969

    Default Function

    I&#039m having trouble using a function <BR>lets say I use a function to find all nulls<BR>and if it&#039s null replace it with the word null<BR>I&#039m using SQL 7.0<BR><BR> Function CheckNull(String)<BR> Dim string<BR> if isnull(String) then<BR> CheckNull = null<BR> Else<BR> CheckNull = String<BR> End If<BR> End Function<BR><BR>on my insert....<BR>I would use<BR>sql = sql "&#039" & checkNull(variable) & "&#039"<BR><BR>For what ever reason this does not work....I end up having to put the function for each variable.....<BR><BR>

  2. #2
    Steve Cimino Guest

    Default RE: Function

    I&#039m assuming your giving us an example in pseudocode, since String would need to be followed by an ASCII value or a literal.<BR><BR>Anyways, why do it this way? Bang open the Query analyzer and change all the values, and have your DBA or yourself have a default value of the field &#039NULL&#039 instead of NULL. That way, this is a one time gig, and you won&#039t have to worry about it again, therefore living happily ever after.<BR><BR>UPDATE whatever<BR>SET field = &#039NULL&#039<BR>WHERE field = NULL

  3. #3
    Join Date
    Dec 1969

    Default No, simple coding goof

    if isnull(String) then<BR>CheckNull = null<BR>Else<BR><BR>**************<BR><BR>That doesn&#039t "replace it with the word null". That simply replaces it with...null. The same thing it already is!<BR><BR>Didn&#039t you mean to do<BR><BR>if isnull(String) then<BR>CheckNull = "null" &#039 &#060;&#060;&#060; $$$ note the quotes!<BR>Else<BR><BR>???<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts