VB.Net - SQL Query to Update Field to Null

Posted on 2013-02-06
Last Modified: 2013-02-07
Good Day Experts!

Another first in my coding career.  In my program, I need to update a SQL table field to Null.  However, in my query I am not sure how to specify to set the field to Null.

How to I set to Null?

Update Customers set TimeEntered = NULL ?

Question by:Jimbo99999
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 75

Accepted Solution

Aneesh Retnakaran earned 200 total points
ID: 38861736
thats right

Update Customers set TimeEntered = NULL
LVL 92

Assisted Solution

by:Patrick Matthews
Patrick Matthews earned 50 total points
ID: 38861737
Assuming your column allows nulls to start with, yes, that is exactly how you would do it :)
LVL 66

Expert Comment

by:Jim Horn
ID: 38861738
>Update Customers set TimeEntered = NULL ?
In T-SQL this is correct for all rows.  
If you only wish to do this for a subset of rows, you'll have to add a WHERE clause at the end.


Update Customers set TimeEntered = NULL WHERE id = SomeNumber
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.


Expert Comment

ID: 38861739
Update Customers set TimeEntered = NULL
Update Customers set TimeEntered = ""
Depending on where you are writing it to.
Double quotes is a blank field and will be seen as a NULL.
LVL 39

Expert Comment

ID: 38861936
@Sodea63: Null and blank are two different values.
LVL 50

Expert Comment

ID: 38861999
update yourtable
  set yourcolumn = nullif(yourcolumn,yourcolumn)
 where yourcolumn is not null
LVL 10

Expert Comment

by:Monica P
ID: 38863136
If you insert NULL ., you need to handle NULL while fetching also in code

if Not isdbnull(reader.item("CreateDate") then
//Your code here
End if

Author Closing Comment

ID: 38863978

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s quite interesting for me as I worked with Excel using for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question