VB.Net - SQL Query to Update Field to Null

Good Day Experts!

Another first in my coding career.  In my VB.net 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 ?

Thanks,
jimbo99999
Jimbo99999Asked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Aneesh RetnakaranConnect With a Mentor Database AdministratorCommented:
thats right

Update Customers set TimeEntered = NULL
0
 
Patrick MatthewsConnect With a Mentor Commented:
Assuming your column allows nulls to start with, yes, that is exactly how you would do it :)
0
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
>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.

like..

Update Customers set TimeEntered = NULL WHERE id = SomeNumber
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
SteveCommented:
Either:
Update Customers set TimeEntered = NULL
Or:
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.
0
 
appariCommented:
@Sodea63: Null and blank are two different values.
0
 
LowfatspreadCommented:
update yourtable
  set yourcolumn = nullif(yourcolumn,yourcolumn)
 where yourcolumn is not null
0
 
Monica PSoftware DeveloperCommented:
If you insert NULL ., you need to handle NULL while fetching also in vb.net code


if Not isdbnull(reader.item("CreateDate") then
//Your code here
End if
0
 
Jimbo99999Author Commented:
Thanks,
jimbo99999
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.