Solved

VB.Net - SQL Query to Update Field to Null

Posted on 2013-02-06
8
785 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
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
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
 
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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

773 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