Solved

sql server 2008  NULLS in Data

Posted on 2014-10-04
3
559 Views
Last Modified: 2014-11-03
HI all,
I'm working on a data migration project and have to transfer data to clients sql server. In my source I have lot of NULL values in some of the columns. what is the best practice. Where ever nulls are in source should I replace them with ''  and then send them the data OR leave nulls as it is as they can query nulls easily than empty fields?
What is the common and best practice. What if they export these nulls to excel. Will it show them nulls too.  Please suggest.
0
Comment
Question by:BI 0824
3 Comments
 
LVL 12

Accepted Solution

by:
James Elliott earned 150 total points
ID: 40361962
NULL is the absence of data. I personally would not change that. SQL handles nulls very well.

Here are some functions that do it:

http://www.w3schools.com/sql/sql_null_values.asp
0
 
LVL 65

Assisted Solution

by:Jim Horn
Jim Horn earned 150 total points
ID: 40362170
The topic of NULL vs. '' or 0 or some other character is always a big topic of debate.  Most developers would prefer the NULLs, as there is a big difference between the absense of data (posted above) and a zero, but in some cases based on business need another character is preferred.   Most business people have no frEEaking clue what 'NULL' means, and it only confuses them.

>What if they export these nulls to excel.
Excel often interprets a NULL as the string 'NULL', and write it out when a data set is exported to Excel.  In that case it may be advisable to write a query that replaces the NULL values with '', and export the query.

>What is the common and best practice
Use the ISNULL or COALESCE functions to convert NULLs into some other value.
0
 
LVL 69

Assisted Solution

by:ScottPletcher
ScottPletcher earned 200 total points
ID: 40364173
From a purely data perspective, NULLs are extremely valuable in differentiating between unknown/missing data and known data that is actually 0 or blank ('').  From the data side, NULLs are in invaluable advantage that should not be given up.

From the purely development and querying side, NULLs are a royal pita.  Writing queries to properly handle NULLs can be quite tricky, even for those who moderately understand NULLs, but are not really expert at it.  This is particularly true for "not equal" conditions.  For example, if you write " state <> 'FL' " in a query, you might expect to see NULL states, but you won't.

Then what to do?  I suggest that data accuracy/integrity is the most important part of a database.  Therefore, I'd opt to use NULLs and give clear guidelines to developers/power users that write queries on how to properly deal with NULLs.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
In this article I will describe the Backup & Restore 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.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

762 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

18 Experts available now in Live!

Get 1:1 Help Now