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 Development (2000)
 varchar or bigint?

Author  Topic 

slaurent
Starting Member

6 Posts

Posted - 2004-06-10 : 10:31:48
Hi All,

I need to store a customer number which is a 19 digits number.
What will be the best to use performance wise when querying on the customer number? a bigint or a varchar (i have a clustered index on the field)?

Thanks
Stephanie

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2004-06-10 : 10:36:27
bigint will be quicker if you are retrieving or joining on the field...
Go to Top of Page

JasonGoff
Posting Yak Master

158 Posts

Posted - 2004-06-10 : 10:36:58
a BIGINT has a maximum value of 9223372036854775807, so if your cust number can exceed that, it's no good. Have you considered using NUMERIC(19,0) ? Would be better than a varchar.
Go to Top of Page

slaurent
Starting Member

6 Posts

Posted - 2004-06-10 : 10:39:25
good point!
will check that.
Thanks
quote:
Originally posted by JasonGoff

a BIGINT has a maximum value of 9223372036854775807, so if your cust number can exceed that, it's no good. Have you considered using NUMERIC(19,0) ? Would be better than a varchar.


Go to Top of Page

steelkilt
Constraint Violating Yak Guru

255 Posts

Posted - 2004-06-10 : 12:16:32
also I'd steer clear of varchar altogether unless you want to write extra data validation rules up front to prevent users from entering non-numerics in the db.

If it's a number, then stick with some sort of numerical data type, I vote.

cheers
Go to Top of Page

steelkilt
Constraint Violating Yak Guru

255 Posts

Posted - 2004-06-10 : 12:17:23
also I'd steer clear of varchar altogether unless you want to write extra data validation rules up front to prevent users from entering non-numerics in the db.

If it's a number, then stick with some sort of numerical data type, I vote.

cheers
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2004-06-10 : 12:24:59
If your not going to do math on it's char(19) or varchar(19)

Is SSN a number?



Brett

8-)
Go to Top of Page
   

- Advertisement -