473,396 Members | 1,724 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Null How to handle

I already asked this question; however, I am giving all the details
now:

We get large files(millions of records) and we need to load it into our
tables using import export wizard. Some of the fields in the file can
be Null and so we are forced to create table with fields that allow
Nulls with default ''. However when we insert data into these tables
it puts Null in those fields even though we have a default '' (I do not
think we have any work around for that; do we?)

Finally we need to go through each field and update it to '' if it is a
Null and that takes LOT OF TIME.
If (select count (*) from <tablename> where <columname> is Null) >0
Begin
Update <tablename>
set <columnName> = ''
where <columnName> is Null
end

Please let me know if there are any work arounds for this crisis ?
Thank you very much in advance!

Jul 23 '05 #1
1 1288
ge******@hotmail.com wrote:

I already asked this question; however, I am giving all the details
now:

We get large files(millions of records) and we need to load it into our
tables using import export wizard. Some of the fields in the file can
be Null and so we are forced to create table with fields that allow
Nulls with default ''. However when we insert data into these tables
it puts Null in those fields even though we have a default '' (I do not
think we have any work around for that; do we?)


You can eliminate NULLs in the INSERT statement. If your original
statement was:

INSERT INTO DestTable
SELECT MyString, MyNumber, MyDate
FROM ImportFile

then you could rewrite this to:

INSERT INTO DestTable
SELECT COALESCE(MyString,''), COALESCE(MyNumber,0),
COALESCE(MyDate,'19000101')
FROM ImportFile

HTH,
Gert-Jan
Jul 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Bodza Bodza | last post by:
I'm having an argument with an incumbent self-taught programmer that it is OK to use null foreign keys in database design. My take is the whole point of a foreign key is that it's not supposed...
28
by: wwj | last post by:
void main() { char* p="Hello"; printf("%s",p); *p='w'; printf("%s",p); }
8
by: Manish Jain | last post by:
Platform : ASP.Net/C# void SomeFunction(DateTime date) { string text = date.ToString(); //This crashes if date is null } I am using a construct similar to above. I want to check if the date...
7
by: Kevin Cline | last post by:
Why, oh why is it necessary to test an event for null before raising it? Why isn't that case handled automatically, instead of forcing developers to write three lines of wasted boilerplate code...
4
by: ___Newbie___ | last post by:
Hello, Why can't a string handle null values? Do I really need to check with IsDBNull() for null values? e.g. fieldName = reader.GetString(0); if (!reader.IsDBNull(1)) { fieldNationality =...
4
by: wapsiii | last post by:
I'm unsure how best to handle dates from my webforms to my database. Often I have a textbox and a datepicker on a webform. Upon postback dates are received in string format (like DD-MM-YYYY)....
6
by: Dean Slindee | last post by:
I am looking for the "right" way to handle inserting and presenting null date values. Public Const c_NullDate As Date = #12:00:00 AM# If I set the value of a date variable in an SQL Server insert...
5
by: John | last post by:
I just cannot manage to perform a SELECT query with NULL parameter... My CATEGORY table does have one row where TCATEGORYPARENTID is null (real DB null value). TCATEGORYID and TCATEGORYPARENTID...
12
by: p.lavarre | last post by:
Q: The C idea of (pv != NULL) is said most directly in Python ctypes how? A: We are of course supposed to write something like: def c_not_null(pv): return (ctypes.cast(pv,...
11
by: coomberjones | last post by:
I have a few std::strings that I am using to store raw binary data, each of which may very well include null bytes at any point or points. I want to slap them together into a single string, so I...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.