Solved

VB.Net - SQL Query to Update Field to Null

Posted on 2013-02-06
8
775 Views
Last Modified: 2013-02-07
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
0
Comment
Question by:Jimbo99999
8 Comments
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 200 total points
ID: 38861736
thats right

Update Customers set TimeEntered = NULL
0
 
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 :)
0
 
LVL 65

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.

like..

Update Customers set TimeEntered = NULL WHERE id = SomeNumber
0
 
LVL 7

Expert Comment

by:Steve
ID: 38861739
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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 39

Expert Comment

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

Expert Comment

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

Expert Comment

by:Monica P
ID: 38863136
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
 

Author Closing Comment

by:Jimbo99999
ID: 38863978
Thanks,
jimbo99999
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

by Mark Wills Attending one of Rob Farley's seminars the other day, I heard the phrase "The Accidental DBA" and fell in love with it. It got me thinking about the plight of the newcomer to SQL Server...  So if you are the accidental DBA, or, simp…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now