Stored procedure insert null value to date column

  • I created a table ORDER in  which there is a column [OrderDate], type is Date.
    One stored procedure to take parameter @orderdate varchar (30)
    If parameter from winform vb.net pass blank string " " to @orderdate, how to code to insert NULL into the table ORDER?

  • adonetok - Friday, July 27, 2018 5:15 AM

    I created a table ORDER in  which there is a column [OrderDate], type is Date.
    One stored procedure to take parameter @orderdate varchar (30)
    If parameter from winform vb.net pass blank string " " to @orderdate, how to code to insert NULL into the table ORDER?

    INSERT INTO ORDER
    (
      Col1,
      ...
       OrderDate
    )
    SELECT
       @Col1,
       ...
       IIF (@orderdate=' ',NULL,CONVERT(date,@orderdate))

  • Thank you for help.
    It works great!

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply