Results 1 to 10 of 10

Thread: insert null into date fields

Threaded View

  1. #10
    Super Moderator FunkyDexter's Avatar
    Join Date
    Apr 2005
    Location
    An obscure body in the SK system. The inhabitants call it Earth
    Posts
    7,957

    Re: insert null into date fields

    Taking a quick look, I can't see anywhere where you give quoteReq_char a value so it will always be blank.

    Assuming you are giving it a value, then changing this:-
    Code:
    If Val("" & QuoteReq_char) = 0 Then
              SQL = SQL & ", '" & Null & "'"    Else
            SQL = SQL & ", CONVERT(datetime,'" & Format(QuoteReq_char, "MM-DD-YYYY") & "', 103)"
        End If
    to
    Code:
    If Val("" & QuoteReq_char) = 0 Then
              SQL = SQL & ", Null "
        Else
            SQL = SQL & ", CONVERT(datetime,'" & Format(QuoteReq_char, "MM-DD-YYYY") & "', 103)"
        End If
    you'll also need to do something similar with ToCarrier_char. The point is you're building up a string. If you build a vb null (which is an empty string) into it you'll just get a blank so your string will look something like 'SomeVal', '', 'SomeOtherVal'. But if you pass "NULL" as a string then the string will read 'SomeVal', NULL, 'SomeOtherVal' and that's what sql server wants. Does that make sense?


    I'm not familiar with this:-
    If Val("" & QuoteReq_char) = 0
    to check for an empty string but I think it should work. I'd suggest:-
    If QuoteReq_char = ""
    or
    If len(QuoteReq_char) = 0
    are more readable though.
    Last edited by FunkyDexter; Jun 20th, 2008 at 07:35 AM.
    The best argument against democracy is a five minute conversation with the average voter - Winston Churchill

    Hadoop actually sounds more like the way they greet each other in Yorkshire - Inferrd

Posting Permissions

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



Click Here to Expand Forum to Full Width