473,569 Members | 2,790 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Text versus Number field.

I see other posts where some say fields that will hold a number with
leading zeros should be stored as text instead of numbers.

This is very inefficient though, as a string of digit characters takes
up much more memory than a 32bit or even a 64bit int.

Storing as a number still allows for formatting when displaying the
number, correct?

I am creating a table and would like opinions regarding this please.

Nov 13 '05 #1
8 2452
I work for a telephone company and there is a great deal of difference
between local UK numbers (one leading zero), international numbers
(double zero) local numbers (no leading zeros).

Yes i know that you could have an indicator but it is far simpler to
hold numbers in text format for this purpose.

Its possible to argue the case all over the place but experience has
shown me that text for phone numbers always works best.

Just a thought...

Rob.

Nov 13 '05 #2
sh******@cs.fsu .edu wrote:
I see other posts where some say fields that will hold a number with
leading zeros should be stored as text instead of numbers.

This is very inefficient though, as a string of digit characters takes
up much more memory than a 32bit or even a 64bit int.

Storing as a number still allows for formatting when displaying the
number, correct?

I am creating a table and would like opinions regarding this please.


It depends. If there is a requirement to store both of these...

012
0056

....Then a format of a number field cannot do the job. Also if...

012
12
0012

....need to be treated as different entries then a number field cannot do the
job.

The performance differences between using text versus number are largely
theoretical these days. Yes if you were doing massive calculations and ran
a series of timed loops you would see a difference. In any "normal"
situation you will not.

--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com
Nov 13 '05 #3
sh******@cs.fsu .edu wrote in
news:11******** *************@g 14g2000cwa.goog legroups.com:
I see other posts where some say fields that will hold a
number with leading zeros should be stored as text instead of
numbers.

This is very inefficient though, as a string of digit
characters takes up much more memory than a 32bit or even a
64bit int.

Storing as a number still allows for formatting when
displaying the number, correct?

I am creating a table and would like opinions regarding this
please.

Rule #1:
If you will add, divide, multiply or divide this number then
store it as a number.
else
store it as a string
endif

If leading zeroes are important, I suspect that the else
condition will apply.

--
Bob Quintal

PA is y I've altered my email address.
Nov 13 '05 #4
sh******@cs.fsu .edu wrote:
I see other posts where some say fields that will hold a number with
leading zeros should be stored as text instead of numbers.
There are no numbers with leading zeroes. There are just numbers.
This is very inefficient though, as a string of digit characters takes
up much more memory than a 32bit or even a 64bit int.
How many zeroes were you planning to store? Each one is likely to
require one byte.
Storing as a number still allows for formatting when displaying the
number, correct?
Yes.
I am creating a table and would like opinions regarding this please.


Store numbers as numbers. It's easier to have an opinion when one knows
what you are trying to do and why.

--
--
Lyle

"The aim of those who try to control thought is always the same. They
find one single explanation of the world, one system of thought and
action that will (they believe) cover everything; and then they try to
impose that on all thinking people."
- Gilbert Highet
Nov 13 '05 #5
dkintheuk wrote:
Its possible to argue the case all over the place but experience has
shown me that text for phone numbers always works best.


Well, that settles it. Thanks for the ruling.

--
--
Lyle

"The aim of those who try to control thought is always the same. They
find one single explanation of the world, one system of thought and
action that will (they believe) cover everything; and then they try to
impose that on all thinking people."
- Gilbert Highet
Nov 13 '05 #6
Lyle Fairfield wrote:
sh******@cs.fsu .edu wrote:
I see other posts where some say fields that will hold a number with
leading zeros should be stored as text instead of numbers.

There are no numbers with leading zeroes. There are just numbers.
This is very inefficient though, as a string of digit characters takes
up much more memory than a 32bit or even a 64bit int.

How many zeroes were you planning to store? Each one is likely to
require one byte.
Storing as a number still allows for formatting when displaying the
number, correct?

Yes.
I am creating a table and would like opinions regarding this please.

Store numbers as numbers. It's easier to have an opinion when one knows
what you are trying to do and why.

The day I store SSNs and phone numbers as a numeric field and not as an
alphanumeric field is the day after I retire from programming and
progress to another type of work.
Nov 13 '05 #7

<sh******@cs.fs u.edu> wrote
I see other posts where some say fields
that will hold a number with leading zeros
should be stored as text instead of numbers.

This is very inefficient though, as a string
of digit characters takes up much more
memory than a 32bit or even a 64bit int.

Storing as a number still allows for formatting
when displaying the number, correct?

I am creating a table and would like
opinions regarding this please.


One general rule that seems to work well is to store in numeric field format
if the number is to be used in calculations; store in text if the "number"
is for identification. After a few years in the application development
business, I am no longer surprised when a "Product ID Number" turns out to
have alphabetic characters, or when the client later decides to use
alphabetic characters in a previously all-numeric identification.

Lyle is correct... "leading zeros" are only a particular format for
displaying numbers. 000012 is the same number as 0012 or 12. Rick is
correct... if 000012 is different from 0012 or 12, you are not talking about
numbers, but about numeric characters which you will have to store in text.
Nov 13 '05 #8
Oooo you are cheeky!

Its nice to know that I'm not bonkers after all now i've looked at the
other answers. They also explain it better i.e. calculations use
numeric, idnetifiers use alphanumeric... easy.

Rob.

Nov 13 '05 #9

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

Similar topics

2
3763
by: Irwinsp | last post by:
Hi All, I have a form with an auto number field displayed. The field looks great except when the user is entering a new record. The field then has the text "auto number" in it. Is there a better way to display this field. I thought the number assigned to this record should be displayed while the user is entering the rest of the form data....
6
4803
by: Sami | last post by:
Problem: Social Security number being used in a database. First problem is that it will not permit numbers beginning in zero to be entered - it sees it as a null or empty space from what I can tell. Next, foreign students have & as the initial part of their SSN. How to do this?? Finally, how do I force the cursor to the far left of...
2
1606
by: Megan | last post by:
Hi everyone- I'm trying to convert social security numbers from a text data type to a number data type, but I lose data on some of the social security numbers, especially SS#s with 0's in them. For example: 123-45-6789 might become 45-6789. This happens in about 20% of the SS#s. I tried opening the table then switching text to number. I...
2
4164
by: Jon Lapham | last post by:
I have a table that stores TEXT information. I need query this table to find *exact* matches to the TEXT... no regular expressions, no LIKE queries, etc. The TEXT could be from 1 to 10000+ characters in length, quite variable. If it matters, the TEXT may contain UNICODE characters... Example: CREATE TABLE a (id SERIAL, thetext TEXT);...
2
1925
by: Carrie | last post by:
I have a number field with some numbers containing a decimal and some numbers with no decimal. In the code behind I put it into a decimal variable and to show this on a label I have the text of the label equal to this "Text='<%# DataBinder.Eval(Container, "DataItem.Num") %>'" SO, what comes to me is all numbers and 2 digits after decimals like...
4
2888
by: Paul J. Lucas | last post by:
I have a simple form that contains an INPUT element that has an initial value. <form name="Form"> <input name="Number" type="text" value="Hello"> </form> When the form loads, I want all of the text in the field to be automatically selected. How can I do this?
0
1538
by: Akaata | last post by:
Hi, How to change a text field into a number field using DB2 spufi? The text field contained a number value. Tia
12
3856
by: Coni | last post by:
Hi All, I am working in Access to print Invoices. On each invoice there is a line number column which is a field to number each line for a product purchase. I would like to know if there is a way to reset the number field (line-number field) to 0 for each invoice created. This would be incremented by 1 for each product purchase. Example...
2
1683
by: Suhas Parchure | last post by:
I want a text field which should accept only text not number . How can i do that?
0
7921
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8118
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7666
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6278
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5504
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5217
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3651
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2107
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
936
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.