Solved

How to handle N/A or Unknown Data

Posted on 2011-02-24
6
328 Views
Last Modified: 2012-05-11
Hi,

I have a field that takes numbers, a double type 100.45. However, the user says that sometimes the value is unknown. So, there are like two states for this field:

1. A number 0 to 1,000
2. Unknown or N/A value. Somebody has not measured it yet, so there is no value yet.

How can I design my table or the column to handle values like this and cover both states? I like to have a column with numbers only, and no chars in it to keep data integrity.

Any suggestions on how to handle this?

Thanks


0
Comment
Question by:gtrapp
6 Comments
 
LVL 29

Accepted Solution

by:
Paul Jackson earned 250 total points
Comment Utility
Just allow nulls in the column definition.
0
 
LVL 40

Assisted Solution

by:Sharath
Sharath earned 125 total points
Comment Utility
If possible, define your column as decimal(6,2) and insert N/A, Unknown values as NULL. If that is not possible and you have to have N/A and Unknown,
you have to define your column as varchar to hold string data.
0
 
LVL 32

Expert Comment

by:ewangoya
Comment Utility

The best way is to use nulls for unassigned values
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 29

Assisted Solution

by:Paul Jackson
Paul Jackson earned 250 total points
Comment Utility
If you allow nulls when you do a select you can handle the null using the ISNULL function like this :

Select ISNULL(mycolumn, 'N/A')
FROM mytable

This will return the column value if not null and return what is specified in the quotes if it is null.
0
 
LVL 57

Assisted Solution

by:Raja Jegan R
Raja Jegan R earned 125 total points
Comment Utility
>> 1. A number 0 to 1,000
2. Unknown or N/A value.

Since you have stored character values in a numeric column, the best way without altering the table would be to use ISNUMERIC function as given below:

SELECT * FROM ur_table
WHERE ISNUMERIC(ur_column_name) = 1

If you are ok to change table structure along with data, then change your column datatype to INT and change those invalid characters as 0 or null..
0
 

Author Closing Comment

by:gtrapp
Comment Utility
Thanks for the advice,
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

744 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

12 Experts available now in Live!

Get 1:1 Help Now