Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 SSN - int vs. char 9

Author  Topic 

apociecha
Starting Member

17 Posts

Posted - 2003-04-30 : 14:47:37
I read some info on what data types are best used for what kind of data and I wonder if I understood correctly that if you have a field, such as a SS#, which is composed of all numerics, you are better off storing that as an integer rather than a character data type. Is that a correct assumption?

Thanks very much,

Agnes



AjarnMark
SQL Slashing Gunting Master

3246 Posts

Posted - 2003-04-30 : 14:57:45
Sometimes, but not always. For example, I'm working on a financial system that has account numbers (assigned by outside companies). These account numbers may have leading zeroes, and these are significant for the outside companies we interact with. If I store the account number as a varchar, I can leave the leading zeroes in there. If I store it as an int, the zeroes disappear. And in our case, between companies, there is not a fixed length where we could just format the number for output easily. So we store them as varchar and don't get stressed over it.

Also there's the issue of length. Numeric formats have range limitations. BUT, if I'm going to be doing any kind of math on an item, then I will definitely store it in a numeric format.
------------------------------------------------------
The more you know, the more you know you don't know.

Edited by - AjarnMark on 04/30/2003 14:59:36
Go to Top of Page

JustinBigelow
SQL Gigolo

1157 Posts

Posted - 2003-04-30 : 14:59:09
IMHO if you aren't going to be performing mathematical functions on the value then it should be stored as char/varchar. That it happens to be comprised of only numbers is a coincidence.

Justin

"Blue canary in the outlet by the light switch / Who watches over you."

Edited by - justinbigelow on 04/30/2003 15:00:10
Go to Top of Page

apociecha
Starting Member

17 Posts

Posted - 2003-04-30 : 16:24:30
Thanks to both of you for your input...it is much appreciated.

I read this stuff about data type performance tuning tips where I found a lot of good information, but I really wasn't sure if it was necessary to store my ss# (or other numeric value fields) in an int vs. char field.

Thanks again. Below is the link if anyone is interested.

Agnes


http://www.sql-server-performance.com/datatypes.asp

Go to Top of Page
   

- Advertisement -