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 2005 Forums
 Transact-SQL (2005)
 Best data type for this

Author  Topic 

Mondeo
Constraint Violating Yak Guru

287 Posts

Posted - 2008-12-09 : 05:51:08
Hi,

I've got a DB which contains column for UK Banks sorting code - this is a 6 digit number which can have zeros anywhere for example these are all valid

010135
003453
814567

I need to index this column so I was wondering about the best datatype, currently its varchar(6), I wasn't sure about using a numeric type because of the leading zeros?

Opinions?

Thanks

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-12-09 : 06:19:36
If you know the bank account numbers always will be six digits, you can use INT and show the leading zeros when needed by adding them at the presentation layer.
If there are not many bank accounts, you can use VARCHAR(6) even if this means 50% more storage space.



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page
   

- Advertisement -